ash: rm -f can fail

Laurent Bercot ska-dietlibc at skarnet.org
Thu Aug 13 11:00:26 UTC 2015


On 13/08/2015 12:36, Bastian Bittorf wrote:
> maybe this is a race?
>
> root at box:~ rm -fR /tmp/dbcache
> rm: can't remove '/tmp/dbcache': Directory not empty
> root at box:~ echo $?
> 1

  Most likely a race. It's impossible to atomically remove
a directory with Unix.

  (There's a way to emulate that: first rename() the directory
to something unique and unpredictable, then rm -rf that
directory. But AFAIK, no rm implementation proceeds like this,
and there's still a small risk that it won't work.)

-- 
  Laurent



More information about the busybox mailing list