Locking a file for race conditons perl -
i working on script no reason spawns 2 processes when run. combat wrote file lock routine. because these processes running @ same time not seem work @ all. missing here.
my $lockfile = '/tmp/lockfile'; $fhpid; sub bailout { print "$0 running. exiting.\n"; print "(file '$lockfile' locked).\n"; exit(1); } open($fhpid, '>', $lockfile) or die "error: open '$lockfile': $!"; flock($fhpid, lock_ex|lock_nb) or bailout();
Comments
Post a Comment