Gary already pointed to SMF contracts, but one other option if you want to use pure locking is to use the "lockfile" program that comes with procmail, for email. Even though this may be a bit heavy handed for performance.

If you know you have a limited use case (all processes on the same host, non-NFS filesystem, only Illumos) then the problem becomes simpler, but if not then the people who've worked out how to lock mailbox files have worked out all of the ugly corner cases on different systems.

Hugh.


On 5/30/13 11:17 AM, Tim Mooney wrote:
In regard to: Re: [OpenIndiana-discuss] shell script mutex locking or...:

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),

In my experience, mkdir is also the easiest reliable mechanism.

It's perhaps unfortunate that there's an ipcs and an ipcrm, but no
ipcmk.  That would be the logical way to do what the original poster
is asking about.

Tim


_______________________________________________
OpenIndiana-discuss mailing list
[email protected]
http://openindiana.org/mailman/listinfo/openindiana-discuss

Reply via email to