Last active
November 11, 2016 10:42
-
-
Save olegwtf/68e859016c2602ac4342b4c8e2a93b25 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ScriptLock; | |
use strict; | |
use FindBin; | |
use Fcntl ':flock'; | |
my $fh; | |
sub import { | |
return if $fh; | |
open $fh, '<', "$FindBin::Bin/$FindBin::Script" | |
or die "open: $!"; | |
flock $fh, LOCK_EX|LOCK_NB | |
or die "flock: $!"; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment