Commit eecfaabc authored by Gavin Brown's avatar Gavin Brown

try to obtain a lock on the script file as a simple way of preventing multiple...

try to obtain a lock on the script file as a simple way of preventing multiple instances from running at the same time
parent 26e84af7
......@@ -2,6 +2,7 @@
# Copyright 2014 CentralNic Ltd. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
use Config::Simple;
use Fcntl qw(:flock);
use Getopt::Long;
use POSIX;
use Pod::Usage;
......@@ -11,6 +12,12 @@ use strict;
openlog('dsd-cp', 'ndelay,perror,pid', LOG_DAEMON);
open(SELF, __FILE__);
if (!flock(SELF, LOCK_EX|LOCK_NB)) {
syslog(LOG_INFO, "Another instance is running");
exit(0);
}
my $file = '/etc/dsd.conf';
my $help;
my $stdin;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment