in reply to Re: Perl Daemons and SIGHUP
in thread Perl Daemons and SIGHUP
I have installed the signal handler as you advised me. but still the exec call terminates the process and i don't know why.
Here is the code:#!/usr/bin/perl -w use strict; use Socket; use Carp; use MTS; use MTS qw(prepare_transaction); use Proc::Daemon; use File::Temp qw(tempfile); use Data::Dumper; use Logger::Syslog; use JSON; use File::Find; use File::Basename; use Cwd 'realpath'; use POSIX (); #use FindBin(); use File::Spec::Functions qw(rel2abs catfile); no warnings 'File::Find'; my $SELF = rel2abs($0); my @argv = @ARGV; # Daemonizing Proc::Daemon::Init unless defined($ENV{"DEBUG"}); use vars qw($mts $qtime $qattr $qsender $qempty $qxtra $qend @template + $PORT @rcpts $pid $lock_dir @children $cfg $CONFIG_FILE); $CONFIG_FILE = '/etc/mts/mts.conf'; # # Forward Declarations # sub spawn; sub _dispatcher; sub _check_spam; sub _process_request; sub _build_msg; sub _enqueue_messages; sub _prepare_message; sub _notify; sub _signal_handler; sub _recover_transactions; sub _lock_maildrop_dir; sub _read_config; sub _reload_config; $SIG{CHLD} = \&REAPER; $SIG{HUP} = \&sigHUP_handler; #$SIG{__DIE__} = 'IGNORE'; $SIG{ABRT} = \&_signal_handler; $SIG{TERM} = \&_signal_handler; $SIG{INT} = \&_signal_handler; _read_config; #print Dumper $cfg; sub sigHUP_handler { #_reload_config; debug("Restarting daemon with: \$SELF=$SELF and \@argv=@argv "); exec($SELF,@argv); } # POSIX unmasks the sigprocmask properly #my $sigset = POSIX::SigSet->new(); #my $action = POSIX::SigAction->new('sigHUP_handler', $sigset, &POSIX: +:SA_NODEFER); #POSIX::sigaction(&POSIX::SIGHUP, $action); #$action = POSIX::SigAction->new('_signal_handler', $sigset, &POSIX::S +A_NODEFER); #POSIX::sigaction(&POSIX::SIGTERM, $action); #POSIX::sigaction(&POSIX::SIGINT, $action); #POSIX::sigaction(&POSIX::SIGABRT, $action);
pay attention to the commented code block which uses POSIX. This does the same problem too
10x
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Perl Daemons and SIGHUP
by moritz (Cardinal) on Feb 24, 2010 at 13:09 UTC | |
by explodec14 (Novice) on Feb 24, 2010 at 13:19 UTC | |
by mje (Curate) on Feb 24, 2010 at 13:33 UTC | |
by explodec14 (Novice) on Feb 24, 2010 at 14:08 UTC | |
by mje (Curate) on Feb 24, 2010 at 16:45 UTC | |
|