[PATCH] signal handlers setup
Greg Banks
gnb at fastmail.fm
Tue Oct 11 02:16:53 EDT 2011
On 11/10/11 16:57, Bron Gondwana wrote:
> On Tue, Oct 11, 2011 at 02:51:25AM +0200, Thomas Cataldo wrote:
>> While testing some java code that executes cyrus init script, I came into a
>> problem : the Java VM blocks SIGQUIT, event when using -Xrs parameter.
>
> Why Java?
That's your bug right there :)
>
>> As SIGQUIT is safe shutdown, I need the signal delivered correctly. I came
>> up with the attached patch that resets the signal mask for cyrmaster before
>> setting the signal handlers.
>>
>> diff --git a/master/master.c b/master/master.c
>> index 823be06..f2ca72e 100644
>> --- a/master/master.c
>> +++ b/master/master.c
>> @@ -1064,7 +1064,11 @@ void sigalrm_handler(int sig __attribute__((unused)))
>> void sighandler_setup(void)
>> {
>> struct sigaction action;
>> -
>> + sigset_t all_signals;
>> +
>> + sigfillset(&all_signals);
>> + sigprocmask(SIG_UNBLOCK, &all_signals, NULL);
>> +
>> sigemptyset(&action.sa_mask);
>> action.sa_flags = 0;
>
> Greg - you know signal handling better than me. What do you think?
>
Patch looks fine, thanks Thomas.
FWIW I don't see any point explicitly unblocking all the signals,
including ones other than the ones we're about to explicitly setup
handlers for, but that's probably harmless.
Also, as a defensive programming measure it's probably a good idea to
memset() that struct sigaction to zero rather than explicitly initialise
some of its members.
--
Greg.
More information about the Cyrus-devel
mailing list