Subject: bug#24714: delete-directory race condition

From: Eli Zaretskii <[email-masked]>
Date: Mon, 17 Oct 2016 19:11:05 +0300

> From: Glenn Morris <[email-masked]>
> Cc: [email-masked]
> Date: Mon, 17 Oct 2016 11:52:31 -0400
> 
> Eli Zaretskii wrote:
> 
> >> will fail with "No such file or directory" if a file in /tmp/foo
> >> happen to be deleted by some other process in between the time that
> >> delete-directory calls directory-files and the time it calls delete-file.
> >
> > IMO, delete-directory should simply catch ENOENT errors and ignore
> > them when it deletes files and subdirectories under the "recursive"
> > option.
> 
> I don't think that's enough, since a file could equally well be
> _created_ by some other process after delete-directory calls directory-files.

It will solve your use case, with files under /tmp, won't it?  A
partial solution is better than no solution at all, IMO.

> Frankly I don't see how Emacs's delete-directory can work reliably as
> currently implemented.

Patches to reimplement it are also welcome.