in reply to Make a perl script self aware...
I think the canonical way to do this (in a script not a module) is
use Fcntl ':flock'; # import LOCK_* constants INIT{ open *{0} or die "What!? $0:$!"; flock *{0}, LOCK_EX|LOCK_NB or die "$0 is already running somewhere!\n"; }
It has one disadvantage that on at least one system and on one version of Perl (AS635 on Win2k) you won't see any error message or script generated message as Perl will fail (quietly!?) if you try to run the script while it is already running.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Make a perl script self aware...
by waswas-fng (Curate) on Aug 01, 2003 at 19:26 UTC |