Creating a lock file in csh?

Ronald S H Khoo ronald at robobar.co.uk
Wed Apr 17 07:46:11 AEST 1991


tchrist at convex.COM (Tom Christiansen) writes:

> I would strongly counsel against using csh.  Use a Bourne-compatible shell.

Strongly seconded.

> Yes, it makes a difference whether you're
> using NFS: old assumptions about idempotency of operations (like create
> or unlink or O_EXCL) are no longer valid;

Actually, I've seen O_EXCL fail on local filesystems too.  Never trust
O_EXCL, it's a flag from hell.

> lockdaemon_from_hell to make these things work.
> And anyway, you can't get 
> to fcntl() from a shell script anyway.  

Surely NFS can't possibly break link(2) based locks ?  I fail to see how
*any* Unixoid filesystem can possibly survive AT ALL if link() doesn't
work.  If it's OK, the original poster can achieve locking at the
shell level using the same techniques as C News does.

C News provides the necessary program (/etc/link lookalike) for those
who haven't got it, and there's even a tutorial on how to do a simple
form of reliable locking *portably* under all kinds of Unix.  I think
the original poster should at least grab pub/c-news/c-news.tar.Z from
ftp.cs.toronto.edu and read the file notebook/newslock in there.
It's not actually particularly news-specific, more a general purpose
simple locking mechanism that *works*, although it does have its
shortcomings.

-- 
Ronald Khoo <ronald at robobar.co.uk> +44 81 991 1142 (O) +44 71 229 7741 (H)



More information about the Comp.unix.shell mailing list