summaryrefslogtreecommitdiff
path: root/FS/FS/Daemon.pm
diff options
context:
space:
mode:
authorivan <ivan>2010-06-16 19:41:24 +0000
committerivan <ivan>2010-06-16 19:41:24 +0000
commit0743ea91445e0682a00a05a0ae8f72e587d6a0e9 (patch)
tree1244c3b0e67b008a79550f7e086d7c6b7813d84d /FS/FS/Daemon.pm
parentaefd60e83ca6b479b9190ec073fe162847b04a7f (diff)
a local XML-RPC server for ncic: daemonize and respond to TERM, RT#7780
Diffstat (limited to 'FS/FS/Daemon.pm')
-rw-r--r--FS/FS/Daemon.pm11
1 files changed, 8 insertions, 3 deletions
diff --git a/FS/FS/Daemon.pm b/FS/FS/Daemon.pm
index f92a2ee..38e6d75 100644
--- a/FS/FS/Daemon.pm
+++ b/FS/FS/Daemon.pm
@@ -1,7 +1,7 @@
package FS::Daemon;
use vars qw( @ISA @EXPORT_OK );
-use vars qw( $pid_dir $me $pid_file $sigint $sigterm $logfile );
+use vars qw( $pid_dir $me $pid_file $sigint $sigterm $NOSIG $logfile );
use Exporter;
use Fcntl qw(:flock);
use POSIX qw(setsid);
@@ -19,6 +19,8 @@ use Date::Format;
$pid_dir = '/var/run';
+$NOSIG = 0;
+
sub daemonize1 {
$me = shift;
@@ -41,8 +43,10 @@ sub daemonize1 {
#$SIG{CHLD} = \&REAPER;
$sigterm = 0;
$sigint = 0;
- $SIG{INT} = sub { warn "SIGINT received; shutting down\n"; $sigint++; };
- $SIG{TERM} = sub { warn "SIGTERM received; shutting down\n"; $sigterm++; };
+ unless ( $NOSIG ) {
+ $SIG{INT} = sub { warn "SIGINT received; shutting down\n"; $sigint++; };
+ $SIG{TERM} = sub { warn "SIGTERM received; shutting down\n"; $sigterm++; };
+ }
}
sub drop_root {
@@ -99,3 +103,4 @@ sub _logmsg {
close $log;
}
+1;