--- a/wgnd-watch.pl Thu May 03 14:53:46 2012 +0200
+++ b/wgnd-watch.pl Thu May 03 15:14:47 2012 +0200
@@ -34,6 +34,8 @@
use Linux::Inotify2;
use Sys::Syslog;
+my $master;
+
BEGIN {
openlog($ME, 'ndelay,nowait,pid', 'LOG_USER');
@@ -101,6 +103,7 @@
or die "Can't open '>', '$opts{pidfile}': $!\n";
print P $$;
close P;
+ $master = $$;
}
@@ -143,7 +146,7 @@
END {
- unlink $opts{pidfile} if $opts{daemon};
+ unlink $opts{pidfile} if $opts{daemon} and defined $master and $master eq $$;
dolog "exit";
closelog;