From: mquinson Date: Mon, 10 Nov 2008 15:40:02 +0000 (+0000) Subject: Add some basic file locking to prevent parallel invocations of the script: only one... X-Git-Tag: v3.3~108 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d8ccdbcf736474f1f05e92ed439a56adbc52f216?hp=b8892821525cf5204c842476d26f530ddcca4908 Add some basic file locking to prevent parallel invocations of the script: only one is needed, so cancel the other ones git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6013 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/tools/sg_unit_extractor.pl b/tools/sg_unit_extractor.pl index 4e233f1e17..37b702593e 100755 --- a/tools/sg_unit_extractor.pl +++ b/tools/sg_unit_extractor.pl @@ -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