equal
deleted
inserted
replaced
31 #use File::Rsync; |
31 #use File::Rsync; |
32 use Getopt::Long; |
32 use Getopt::Long; |
33 use Pod::Usage; |
33 use Pod::Usage; |
34 use Linux::Inotify2; |
34 use Linux::Inotify2; |
35 use Sys::Syslog; |
35 use Sys::Syslog; |
|
36 |
|
37 my $master; |
36 |
38 |
37 BEGIN { |
39 BEGIN { |
38 |
40 |
39 openlog($ME, 'ndelay,nowait,pid', 'LOG_USER'); |
41 openlog($ME, 'ndelay,nowait,pid', 'LOG_USER'); |
40 $SIG{__WARN__} = sub { |
42 $SIG{__WARN__} = sub { |
99 |
101 |
100 open(P, '>', $opts{pidfile}) |
102 open(P, '>', $opts{pidfile}) |
101 or die "Can't open '>', '$opts{pidfile}': $!\n"; |
103 or die "Can't open '>', '$opts{pidfile}': $!\n"; |
102 print P $$; |
104 print P $$; |
103 close P; |
105 close P; |
|
106 $master = $$; |
104 |
107 |
105 } |
108 } |
106 |
109 |
107 my $inotify = new Linux::Inotify2 |
110 my $inotify = new Linux::Inotify2 |
108 or die "Can't create new inotify object: $!\n"; |
111 or die "Can't create new inotify object: $!\n"; |
141 |
144 |
142 } |
145 } |
143 |
146 |
144 END { |
147 END { |
145 |
148 |
146 unlink $opts{pidfile} if $opts{daemon}; |
149 unlink $opts{pidfile} if $opts{daemon} and defined $master and $master eq $$; |
147 dolog "exit"; |
150 dolog "exit"; |
148 closelog; |
151 closelog; |
149 |
152 |
150 } |
153 } |
151 |
154 |