Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: File locking within zsh?
- X-seq: zsh-users 10262
- From: Vincent Lefevre <vincent@xxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: File locking within zsh?
- Date: Sat, 13 May 2006 01:24:02 +0200
- In-reply-to: <lt3bffqbf5.fsf@xxxxxxxxxxxxxxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <87r7324zyh.fsf@xxxxxxxxxx> <ltd5emv9lh.fsf@xxxxxxxxxxxxxxxxxx> <009101c673f7$06b3f090$6500000a@venti> <20060510171305.GA4116@xxxxxxxxxxxxxxxxxxx> <009d01c67511$f91c8ed0$6500000a@venti> <20060512075401.GN4116@xxxxxxxxxxxxxxxxxxx> <lt3bffqbf5.fsf@xxxxxxxxxxxxxxxxxx>
On 2006-05-12 15:40:30 -0400, Tim Writer wrote:
> I'm not sure that the symlink() system call is guaranteed to be
> atomic but link() is.
OK for link(). The Linux open(2) man page says:
O_EXCL When used with O_CREAT, if the file already exists it is an
error and the open() will fail. In this context, a symbolic link
exists, regardless of where it points to. O_EXCL is broken on
NFS file systems; programs which rely on it for performing lock-
ing tasks will contain a race condition. The solution for per-
forming atomic file locking using a lockfile is to create a
unique file on the same file system (e.g., incorporating host-
name and pid), use link(2) to make a link to the lockfile. If
link() returns 0, the lock is successful. Otherwise, use
stat(2) on the unique file to check if its link count has
increased to 2, in which case the lock is also successful.
--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA
Messages sorted by:
Reverse Date,
Date,
Thread,
Author