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?


In reply to Re^3: Why this daemon can only receive the HUP signal no more than one time? by Perlbotics
in thread Why this daemon can only receive the HUP signal no more than one time? by sunshine_august

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.