That's correct. First (FWIW) I can confirm your observation (SuSE 11.1, 2.6.27.7-9-pae, perl 5.10.0).
The problem seems to be that your daemon exec's from within the signal-handler (presumably inheriting a blocked signal mask).
After applying a quick and dirty work-around, the program reloaded as expected multiple times.
The work-around was to set a global variable $PLEASE_RELOAD=1; (initialised to 0) within the HUP-handler and
to incorporate something like relaunch( $runDir, $pidFile, $exeFile ) if $PLEASE_RELOAD; into hupMain() allowing to exec outside the HUP signal handler.
This is ugly, but it seems to locate the problem somewhere near the HUP handler...
Another hint: you used a variable called $parentPid to save the children/daemons PID.
Update: Maybe this snipped from perlipc provides a useful hint?
# 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);
sub sigHUP_handler {
print "got SIGHUP\n";
exec($SELF, @ARGV) or die "Couldn't restart: $!\n";
}
Update: Hm, forget to note: SIGHUPSIGTERM (Argl. Sorry, confused that, AM is right,
see below.) is send by the OS on shutdown (usually followed by SIGKILL a little bit later) - this would relaunch your daemon during shutdown.
Maybe it is a better idea to use SIGUSR1 to reload the daemon?
|