bichonfrise74 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use warnings; use strict; use Fcntl qw( :flock ); print "Script $0 is running now.\n"; # Check_Race_Condition(); open( my $self, '<', $0 ) or die( "Another $0 is already running.\n"); flock( $self, LOCK_EX | LOCK_NB ) or die( "Another $0 is already running.\n"); sleep( 100 ); print "End.\n"; sub Check_Race_Condition { open( my $self, '<', $0 ) or die( "Another $0 is already running.\n"); flock( $self, LOCK_EX | LOCK_NB ) or die( "Another $0 is already running.\n"); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Flock and Subroutine
by kennethk (Abbot) on Mar 04, 2010 at 21:15 UTC | |
Re: Flock and Subroutine
by scorpio17 (Canon) on Mar 04, 2010 at 22:20 UTC | |
Re: Flock and Subroutine
by Khen1950fx (Canon) on Mar 05, 2010 at 07:17 UTC |