[comp.unix.sysv386] cu/ecu

les@chinet.chi.il.us (Leslie Mikesell) (05/22/91)

In article <1991May21.132134.4781@newshost.anu.edu.au> cmf851@anu.oz.au (Albert Langer) writes:

>>I'm pretty sure it isn't possible to do locks right in a shell script.

>I was under the impression it is safe to use mkdir since unlike
>linking a file, that is atomic. Anyone disagree?

>[ mkdir $lockdir ] || echo "Already locked"

I don't see any advantage over link.  Link is atomic as long as you
aren't doing it over NFS.  The problem comes when some process leaves
it's lockfile and you have to delete it (normal procedure for
uugetty).  If no process ever deletes any lockfile but its own,
link, mkdir, or mknod (using a fifo), should all succeed or fail
as an atomic operation.

Les Mikesell
  les@chinet.chi.il.us