SPUG: Perl Question?
james at banshee.com
Wed May 4 11:23:50 PDT 2005
> I would recommend instead querying the process table for other processes
> running as $0.
There's no atomic way of doing this that I know about, though. You need
some sort of real mutex mechanism; lock files, semaphores, whatever, but
something that helps you deal with race conditions.
I guess you could do something like look at the process table and declare
that the lowest PID wins; if there's another process running and its PID <
your PID, then you should exit. Feels suspicious, though - am I missing
something that would break this? For one, it's not portable, but I'd also
assume in my suspicious little heart that anything relying on file locking
is going to snap like a twig if you try to go between substantially
different OSes, too.
More information about the spug-list