scottb has asked for the wisdom of the Perl Monks concerning the following question:

In an application I am working on, I am trying to temporarily disallow SIGHUPs from interupting my program (normally they will signal for it to reload configuration information). In these particular circumstances, the program is sent a SIGHUP quite frequently.

I am accomplishing this by setting:

$SIG{HUP} = 'IGNORE';
... as per the Perl documentation:

"You may also choose to assign the strings 'IGNORE' or 'DEFAULT' as the handler, in which case Perl will try to discard the signal or do the default thing."

The problem is that once in a while, I get the following message. The number of times that I get this message is not consistent with the number of times it is being sent a SIGHUP to be ignored; far more often than not, it 'does the right thing' and ignores the signal.

SIGHUP handler "IGNORE" not defined.

Why am I getting this message?

Thanks,
Scott

Replies are listed 'Best First'.
Re: SIGHUP handler "IGNORE" not defined.
by sh1tn (Priest) on Feb 08, 2005 at 22:07 UTC
    You have to assign anonymous subroutine or (better)
    use sigtrap qw(die untrapped normal-signals);
    pragma.

    perldoc sigtrap
      Is there a reason you need to use sigtrap? As the parent post mentions, perldoc perlipc states that perl will try to ignore the action if it is set to 'IGNORE', or use the default action if it is set to 'DEFAULT'.
      Is this a bug in the perldoc? Or is there some other reason for this?
        It is also written in perldoc perlipc:

        Handling the SIGHUP Signal in Daemons
        ...
        Not all platforms automatically reinstall their (native) signal handlers after a signal delivery.
        This means that the handler works only the first time the signal is sent.
        The solution to this problem is to use POSIX signal handlers if available, their behaviour is well-defined.
        I second the question... I have been aware all along that I could "manually override" what would seem to be the proper behaviour of 'IGNORE' by creating my own do-nothing subroutine. But the purpose of my question was to find out exactly what was going wrong under the circumstance, contrary to the documentation.