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

OS Linux RH 7.3, ES2.1, ES3.0 question involves repeated use of signals. I've genned up signal support for INT and HUP as follows:
# # interrupt support # use POSIX; $sigset = POSIX::SigSet->new(); $actINT = POSIX::SigAction->new( 'SigInterrupt', $sigset, &POSIX::SA_N +ODEFER ); $actHUP = POSIX::SigAction->new( 'SigHangup', $sigset, &POSIX::SA_N +ODEFER ); POSIX::sigaction( &POSIX::SIGINT, $actINT ); POSIX::sigaction( &POSIX::SIGHUP, $actHUP ); $SIGINT = 0; $SIGHUP = 0;

The variables $SIG* are just tweaked in the signal handlers. That's all that goes on in the handlers. I look for the tweaked value when I emerge from a select() loop and act accordingly. This all works fine for the first signal processed. SIGINT causes a delayed exit, as desired. SIGHUP causes state info to go to log, as desired. However, repeating SIGHUP after the first SIGHUP doesn't do diddly. Bigger however, repeating SIGHUP *again* does cause the signal to be noticed. And so it goes, with every other SIGHUP signal apparently being noticed. WTH? Signals are sent to the process at a leisurely interval, on the order of seconds, so I am not believing that there are any signal stacking issues going on here. :-)

Can anybody explain this?

Thanks!
rnd

Replies are listed 'Best First'.
Re: POSIX signal handling in Perl 5.6.x
by ruoso (Curate) on Sep 15, 2005 at 17:39 UTC

    My experience with signals says me: "Never use it for important things!". I Once started playing with Signals and Unix Sockets, and I found that it simply didn't work reliably. Signals were lost, conections staled and so on... Ok, this was Linux 2.2 (maybe earlier... it was 1999~2000)... But I still don't trust them for anything else then simple notifications that wouldn't cause the III World War if missed.

    daniel
      The fact that I'm using UDP on the socket in the select() should signal (heh) my reasonable lack of concern about data droppage.

      However, the "every other signal" behavior is too regular to be chance. That's what I'm more than a little curious to understand!