find(1) removes as it should a directory, but after this it complains about

Matthias Apitz guru at unixarea.de
Mon Apr 20 08:16:32 UTC 2020


Hello,

I've stumbled over something with find(1) which I would call a bug:

$ mkdir foo
$ find foo -type d -execdir rm -rv {} \;
foo
find: foo: No such file or directory
$ ls -ld foo
ls: foo: No such file or directory

I truss'ed the find(1) and it starts as it should a child process like
'rm -rv foo', but when this ends correctly, find tries to open again the
dir foo:

$ truss -f -o find.tr find foo -type d -execdir rm -rv {} \;
foo
find: foo: No such file or directory
$ grep foo find.tr
 2107: fstatat(AT_FDCWD,"foo",{ mode=drwxr-xr-x ,inode=4099842,size=512,blksize=32768 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
 2108: fstatat(AT_FDCWD,"foo",{ mode=drwxr-xr-x ,inode=4099842,size=512,blksize=32768 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
 2108: access("foo",W_OK)			 = 0 (0x0)
 2108: open("foo",O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC,03) = 4 (0x4)
 2108: rmdir("foo")				 = 0 (0x0)
 2108: write(1,"foo\n",4)			 = 4 (0x4)
 2107: open("foo",O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC,03) ERR#2 'No such file or directory'
 2107: write(2,"foo: No such file or directory",30) = 30 (0x1e)

Is this by intention?

	matthias


-- 
Matthias Apitz, ✉ guru at unixarea.de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub
May, 9: Спаси́бо освободители! Thank you very much, Russian liberators!


More information about the freebsd-questions mailing list