Creating a lock file in csh?

Anthony Lapadula al at unhd.unh.edu
Tue Apr 16 06:56:54 AEST 1991


I'll soon be writing a script (most likely in csh) that has at least
one critical section (updating a file).  I need to ensure that only
one executing copy of the script actually accesses the file at any
given time.

I had thought that creating a lock file -- and checking for its presence
when starting up -- would be a reasonable way to solve the problem.
I can't seem to figure out how to do it (short of invoking a C program
that invokes open(2) with O_EXCL).  We're trying to keep the script
machine-independent, so the open(2) solution is out.

I looked at mktemp(1), but it also seems insufficient.

Lastly, does it matter that we're using NFS?

Any and all replies welcome.  Thanks in advance.

-- Anthony (uunet!unhd!al, al at cs.unh.edu) Lapadula



More information about the Comp.unix.shell mailing list