[OpenIndiana-discuss] shell script mutex locking or process signaling

Laurent Blume laurent+oi at elanor.org
Thu May 30 14:29:12 UTC 2013


On 30/05/13 16:15, Edward Ned Harvey (openindiana) wrote:
<snip>
> I see there are a bunch of C constructs available ... mutex_init,
> etc.  Surely there must be a wrapper application around this kind of
> thing, right?

I spent some time looking for a lock in shell some time ago. The overall 
conclusion was that the only atomic operation in pure shell is mkdir.

I use /tmp or /var/run so it's at least deleted on reboot, and my 
scripts trap signals so when it ends (either correctly or after being 
interrupted), they do their best to remove it (that works well).
If they do find a lock they don't expect, they scream, since a manual 
intervention is needed.

So far, it works correctly.

Laurent



More information about the OpenIndiana-discuss mailing list