Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: History file locking?
- X-seq: zsh-workers 913
- From: Zoltan Hidvegi <hzoli@xxxxxxxxxx>
- To: A.Main@xxxxxxxxxxxxxxxxx (Zefram)
- Subject: Re: History file locking?
- Date: Wed, 10 Apr 1996 23:21:27 +0200 (MET DST)
- Cc: zsh-workers@xxxxxxxxxxxxxxx (zsh-workers)
- In-reply-to: <20845.199604101250@xxxxxxxxxxxxxxxxxxxxxxx> from Zefram at "Apr 10, 96 01:50:13 pm"
- Organization: Dept. of Comp. Sci., Eotvos University, Budapest, Hungary
- Phone: (36 1)2669833 ext: 2667, home phone: (36 1) 2752368
> >Also things get quite complicated when the history file is on an NFS volume.
> >Probaly some dot-locking method similar to the one used by sendmail & co
> >should be used.
>
> I wouldn't bother -- it's only a history file. lockf() (and fcntl())
> locking work over NFS anyway; it's only flock() that doesn't. O_EXCL
> isn't reliable over NFS, which makes .lock locking rather pointless.
lockf() should work on NFS, but on many systems it doesn't. But properly
implemented .lock works:
1. create a temporary lock file
2. link the temporary lock to the real lock.
If the link succeeds, stat the temporary lock file. It its link count
is 2 the locking really succeded, so remove the temp lock. This stat
trick should work even on NFS.
If the link fails, check the validity of the lock (the lock file should
contain the PID of the locking process) using kill(0, lock_pid). If the
lock is invalid, remove it and repeat step 2.
That works on all systems without configure checks. Configure check for a
working lock method is not simple. The checks should be done using all of
the possible filesystems which zsh may use. Procmail has a test for that,
but I one managed to crach a Solaris machine with it running is as an
ordinal user.
Bye,
Zoltan
Messages sorted by:
Reverse Date,
Date,
Thread,
Author