in reply to Re: Lightweight Solution To "Only 1 Process Running" On AIX
in thread Lightweight Solution To "Only 1 Process Running" On AIX

JavaFan,
The code shown is the extract from the slides presented by Dominus. I provided it here so people wouldn't have to go to an offsite location to see them. Here is complete running code that demonstrates the problem:
#!/usr/bin/perl use strict; use warnings; use Fcntl qw/:DEFAULT :flock/; open(SELF, '<', $0) or die "Unable to open '$0' for reading: $!"; flock SELF, LOCK_EX | LOCK_NB or exit; print "I must be the only process running\n"; sleep 300;
and
#!/usr/bin/perl use strict; use warnings; use Fcntl qw/:DEFAULT :flock/; flock DATA, LOCK_EX | LOCK_NB or exit; print "I must be the only process running\n"; sleep 300; __DATA__

Cheers - L~R