Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [patch] Avoid race in zf_mkdir



On Fri, Oct 9, 2020 at 10:25 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> Er, sorry, this doesn't actually avoid the race, it just prevents the error message from being shown by whichever shell loses the race.

I think this is the expected behavior. It's prescribed by POSIX for mkdir.

> ISometimes you might want to know that the directory was NOT created BY the current shell?

In this case you would invoke zf_mkdir without -p.

> In neither variation are we checking that the existing directory actually has the requested mode.

POSIX says this is how it should be.

Roman.

P.S.

The patch is incorrect for a different reason. If `zf_mkdir -p foo` is
racing with another process that's doing `mkdir foo && rmdir foo`, the
zf_mkdir call must never fail but with this patch it can fail.




Messages sorted by: Reverse Date, Date, Thread, Author