in reply to Re^3: perl threads crashed
in thread perl threads crashed

Thanks very much, i have some misunderstand to the signal, thank you for your tips!

Replies are listed 'Best First'.
Re^5: perl threads crashed
by Marshall (Canon) on Jun 09, 2011 at 02:13 UTC
    Yes, from looking at your code, I think there are some misunderstandings about sigaction and sigprocess masks.

    The sigaction structure contains the rules about how a signal is delivered. You can cause it to be ignored, have the default action taken, or have some code that you supply be run. In addition to that you can specifiy a set of signals to block/unblock while your signal handler is running. This is not the same as you setting a sigproc mask at the start of the handler. The sigaction mask will be in effect before even the first instruction in the handler is executed. When the handler finishes the signal blocking mask goes back to whatever it was before the signal.

    The C code for a normal setup would look like below. I am more familiar with the C, but there are Perl equivalents if you need to deal with this low of a level.

    sigset_t newmask; struct sigaction sa; sa.sa_handler= handler; //handler is name of subroutine sigfillset(&sa.sa_mask); //set up to block all signals sigdelset(&sa.sa_mask, SIGPIPE); // allow SIGPIPE to interrupt handler // normally not done // allowing this is non-typical sa.sa_flags =0; sigaction(SIGUSR1, &sa, NULL);
    Sigproc mask is a whole different thing. It is seldom necessary to mess with this. An example usage might be to temporarily block CTL-C, CTL-\ while updating some critical file. Block some signals, do something, unblock signals. This is different than sigaction mask which is the temporary blocking mask that is only in effect for the duration of the signal handler code.

    Signals are not queued - the state is a yes/no situation. If a signal is blocked and it happens say 5 times. The result of this is that the state is called "pending". This is a signal that has occurred, but has not yet been delivered. When unblocked, the signal will just be delivered once, not 5 times.