fixed accicendal pidfile removal
authorMatthias Förste foerste@schlittermann.de
Thu, 03 May 2012 15:14:47 +0200
changeset 22 bba8b3344c26
parent 21 43a7c833a2bf
child 23 7484e32fdc72
fixed accicendal pidfile removal
debian/changelog
wgnd-watch.pl
--- a/debian/changelog	Thu May 03 14:53:46 2012 +0200
+++ b/debian/changelog	Thu May 03 15:14:47 2012 +0200
@@ -2,4 +2,4 @@
 
   * Initial Release.
 
- -- Matthias Förste <foerste@schlittermann.de>  Mon, 30 Apr 2012 12:11:44 +0200
+ -- Matthias Förste <foerste@schlittermann.de>  Thu, 03 May 2012 15:10:30 +0200
--- 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;