Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add some basic file locking to prevent parallel invocations of the script: only one...
[simgrid.git] / tools / sg_unit_extractor.pl
index 4e233f1..37b7025 100755 (executable)
@@ -1,6 +1,13 @@
 #! /usr/bin/perl
 
 use strict;
+use Fcntl ':flock';
+
+open SELF, "< $0" or die "Cannot open the lock file";
+if (!flock SELF, LOCK_EX | LOCK_NB) {
+    print STDERR "sg_unit_extractor already running. Cancelling...\n";
+    exit;
+}
 
 my $progname="sg_unit_extractor";
 # Get the args