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

Re: History file locking?



> >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