#! /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