Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!bloom-beacon!snorkelwacker!spdcc!ima!cfisun!lakart!dg From: dg@lakart.UUCP (David Goodenough) Newsgroups: comp.unix.questions Subject: Re: Lock Files From Shell Scripts Message-ID: <741@lakart.UUCP> Date: 8 Nov 89 18:23:57 GMT References: <1691@ncrcce.StPaul.NCR.COM> Organization: Lakart Corporation, Newton, MA Lines: 47 mercer@ncrcce.StPaul.NCR.COM (Dan Mercer) sez: > ..... Then I considered using ln, thinking an error > condition would be returned if the file existed. But no, the file > was overwritten unconditionally. Humm - sounds like SYSV and a funky ln. However, if mkdir will overwrite an already existing directory then I'd say you have a really badly broken system. So why not: --- cut here --- cut here --- cut here --- cut here --- cut here --- lock=/tmp/lock until mkdir $lock 2>&1 >/dev/null do sleep 10 done # critical stuff # clean up the lock directory rmdir $lock exit 0 --- cut here --- cut here --- cut here --- cut here --- cut here --- You could also use umask and touch, except touch doesn't return an error status, at least BSD touch doesn't (again, if mkdir doesn't you're in dead trouble anyway) -- dg@lakart.UUCP - David Goodenough +---+ IHS | +-+-+ ....... !harvard!xait!lakart!dg +-+-+ | AKA: dg%lakart.uucp@xait.xerox.com +---+