Help for this page

Select Code to Download


  1. or download this
    #! perl -lw
    use strict;
    ...
    
    flock $fh, LOCK_EX;
    flock $fh, LOCK_EX;
    
  2. or download this
    open my $fh, "<", "whatever" or die $!;
    flock $fh, LOCK_EX;
    ...
    die "open(): $!" unless defined $pid;
    if ($pid > 0) { close $pip }
    else          { flock($fh,LOCK_EX); print "got the lock"}
    
  3. or download this
    if ($pid > 0) { flock($fh,LOCK_EX); print "got the lock" }
    else          { sleep(20) }