Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Any way to allow clobbering empty files when noclobber is set?
- X-seq: zsh-workers 46002
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Any way to allow clobbering empty files when noclobber is set?
- Date: Sat, 6 Jun 2020 08:03:03 +0000
- Cc: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>, Martin Tournoij <martin@xxxxxxxxxx>
- In-reply-to: <CAH+w=7YqAiOdd4sAbSRxghp3RD_qQjfR5V8jT-KhhOOppysv1A@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CGME20200603020919eucas1p13e26ebcbb335784d14bfb97b137f385a@eucas1p1.samsung.com> <89aed74d-db7b-47ad-b218-8158838049e9@www.fastmail.com> <94e73ebcf39d4d3f9c7ae257b1d75d16@CAMSVWEXC01.scsc.local> <CAH+w=7YpQ3CcsMhAvztGHx19FnALBV349RAz4p8iuB+_8AnsxQ@mail.gmail.com> <CAN=4vMqBCZqD04QO-hw0DwipmCVkdq+QNOEGNaSEfNxyRBqiiw@mail.gmail.com> <20200605020748.635b9bb3@tarpaulin.shahaf.local2> <CAN=4vMoC8aNBz=ZAW-BdA9W6MaBXN3SNBPpZZQobVRwjUg2wGQ@mail.gmail.com> <CAH+w=7ZHapcvCZ=QmV2QEBxi1HGwfKOd4dJ47Ndi+5R-V2VDSg@mail.gmail.com> <20200606045531.4b506c8e@tarpaulin.shahaf.local2> <CAH+w=7YqAiOdd4sAbSRxghp3RD_qQjfR5V8jT-KhhOOppysv1A@mail.gmail.com>
Bart Schaefer wrote on Sat, 06 Jun 2020 00:08 -0700:
> On Fri, Jun 5, 2020 at 9:55 PM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> >
> > Bart Schaefer wrote on Fri, 05 Jun 2020 18:41 -0700:
> > >
> > > I don't think that's the intended typical usage of noclobber. It's
> > > not set by default, and it can't have any effect outside the local
> > > shell.
> >
> > NO_CLOBBER causes open() to be called with the O_EXCL bit, which does
> > affect other processes as well.
>
> ?? All that O_EXCL guarantees is that no other process is able to
> create the file. Once it exists, another file can open it and
> truncate it and write to it, unless prevented by umask.
But in Roman's example, _both_ backgrouned processes use O_EXCL, so
whichever process loses the race will get an error when it calls
open(2). Yes, attempts to open() the file without O_EXCL will succeed,
but when a file is used as a mutex, everyone who tries to open the file
will try to use O_EXCL.
Makes sense?
Cheers,
Daniel
Messages sorted by:
Reverse Date,
Date,
Thread,
Author