The semantics for nonblocking flock are to return false if the lock was not obtained, true if it was. If the platform does not support flock a fatal error is thrown.
You are apparantly on a win32ish system, which may or may not support flock, so it would be good to catch the error. See perlport and perlwin32 for details. Try something like this,
For this semaphore system to be effective, the other script should flock the flag file first thing, and drop the lock at the very last, perhaps in a DESTROY() sub.use Fcntl ':flock' ; open ONE, ">> C:\\temp\\RTEOlock.log" or die $!; my $lck = eval {flock ONE, LOCK_EX | LOCK_NB}; die 'flock not supported! ', $@ if $@; if ($lck) { # The other script is not running code here } else { # The other script is running code here }
After Compline,
Zaxo
In reply to Re: use flock() to determine if other script is running
by Zaxo
in thread use flock() to determine if other script is running
by Red_Dragon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |