SPUG: Perl Question?

DeRykus, Charles E charles.e.derykus at boeing.com
Wed May 11 18:23:33 PDT 2005

> For this whole thread I have to admit that I've been thinking people are wasting 
> their time trying to figure ways around using a real mutex facility that's supported 
> by the operating system.  Surely the answer is that you should use the CPAN module 
> that encapsulates this in some reasonably elegant way, right?

> Problem is that I can't find it.  Is there such a beast?  Seems like an obvious need.  
> Candidates like Win32::Mutex fail for obvious reasons. IPC::Semaphore seems like it'd 
> be the right tool for the job, but despite the name it doesn't appear to be portable 
> ("SysV Semaphore IPC object class" pretty much takes it out of contention).  
> What am I missing?

I wonder if  flock with an external file would be reasonably portable..  
(seems to work on Win32 and Solaris).  

use Fcntl qw(:flock);
BEGIN { open MYLOCK, '>', 'mylock' and flock MYLOCK, LOCK_EX|LOCK_NB 
         or die "already running\n";

Charles DeRykus

More information about the spug-list mailing list