[OpenIndiana-discuss] shell script mutex locking or process signaling
Bob Friesenhahn
bfriesen at simple.dallas.tx.us
Thu May 30 18:05:14 UTC 2013
On Thu, 30 May 2013, Edward Ned Harvey (openindiana) wrote:
> I'm looking around, and not finding any great answers. So far,
> using mkdir, it's easy to see there exists a way to do mutex
> locking, and you could easily write your PID into the subdir that
> was just created; unfortunately, the problem is when a script gets
> killed, leaving the stale lock. So I'm looking for something better
> than "mkdir" to use for locking.
Hard links from an existing file are a robust atomic "locking"
mechanism. These have been used on mail servers for several tens of
years such as in /var/mail. The shell supports a signal trap
mechanism so you can handle delivery of a signal and remove the hard
link.
The main thing which is lacking is a way to wait for a lock beyond
simple polling.
Bob
--
Bob Friesenhahn
bfriesen at simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
More information about the OpenIndiana-discuss
mailing list