From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: [patch] Avoid race in zf_mkdir
Date: Fri, 9 Oct 2020 22:35:46 +0200 [thread overview]
Message-ID: <CAN=4vMoJrD+g4Go37yT6gF-Lx61vHm45GvmG1Fx6-+3yyb1hAQ@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7anY9r+-MYki4cycVuaP2+d9L3W5u8k3sHyZx4R5kvafg@mail.gmail.com>
On Fri, Oct 9, 2020 at 10:25 PM Bart Schaefer <schaefer@brasslantern.com> 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.
next prev parent reply other threads:[~2020-10-09 20:36 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-09 20:07 Matthew Martin
2020-10-09 20:24 ` Bart Schaefer
2020-10-09 20:35 ` Roman Perepelitsa [this message]
2020-10-09 20:47 ` Bart Schaefer
2020-10-09 20:53 ` Matthew Martin
2020-10-09 21:22 ` Roman Perepelitsa
2020-10-09 21:27 ` Bart Schaefer
2020-10-10 11:50 ` Roman Perepelitsa
2020-10-15 10:01 ` Roman Perepelitsa
2020-10-15 15:29 ` Bart Schaefer
2020-10-15 15:36 ` Roman Perepelitsa
2020-10-15 16:47 ` Bart Schaefer
2020-10-22 13:30 ` Roman Perepelitsa
2020-10-09 21:40 ` Matthew Martin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAN=4vMoJrD+g4Go37yT6gF-Lx61vHm45GvmG1Fx6-+3yyb1hAQ@mail.gmail.com' \
--to=roman.perepelitsa@gmail.com \
--cc=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).