[m-rev.] For review: Re-throw unhandled signals.

Paul Bone pbone at csse.unimelb.edu.au
Tue May 18 10:16:08 AEST 2010


On Tue, May 18, 2010 at 01:06:30AM +1000, Julien Fischer wrote:
>
> On Thu, 13 May 2010, Paul Bone wrote:
>
>> Re-throw unhandled signals.
>>
>> The Mercury runtime uses signal handlers to implement redzones and to provide
>> extra information in the case of a segmentation violation.  However this
>> prevents Mercury programs from dumping core.  It can also prevent the parent
>> process from knowing that the program was killed by a signal rather than exited
>
>   It also prevents a parent process from distinguishing whether a child
>   was killed by a signal or exited with a non-zero exit status.
>
>> with exit status 1.  This change re-throws signals that cannot be handled so
>> that the program can dump core and does this compatibly with the existing
>> signal handlers.
>
>    ... and does this in a way that is compatible with the existing signal
>    handlers.
>
>> runtime/mercury_memory_handlers.c:
>>    Use MR_reset_signal() and raise() to re-throw signals that we can't handle.
>>
>> runtime/mercury_signal.h:
>> runtime/mercury_signal.c:
>>    Create MR_reset_signal() that resets the handler for a signal back to the
>>    default (SIG_DFL).
>
> ...
>
>> Index: runtime/mercury_signal.c
>> ===================================================================
>> RCS file: /home/mercury1/repository/mercury/runtime/mercury_signal.c,v
>> retrieving revision 1.16
>> diff -u -p -b -r1.16 mercury_signal.c
>> --- runtime/mercury_signal.c	14 Nov 2006 00:15:41 -0000	1.16
>> +++ runtime/mercury_signal.c	13 May 2010 03:34:06 -0000
>> @@ -85,6 +85,26 @@ MR_do_setup_signal(int sig, MR_Code *han
>> }
>>
>> void
>> +MR_reset_signal(int sig)
>> +{
>> +    MR_signal_action    act;
>> +
>> +#ifdef MR_HAVE_SIGACTION
>> +    if (sigemptyset(&(act.sa_mask)) != 0) {
>> +        MR_perror("cannot set clear signal mask");
>> +        exit(1);
>> +    }
>> +    errno = 0;
>> +
>> +    act.sa_flags = 0;
>> +    act.sa_handler = SIG_DFL;
>> +#else
>> +    act = SIG_DFL;
>> +#endif
>> +    MR_set_signal_action(sig, &act, "Couldn't reset signal");
>> +}
>> +
>> +void
>> MR_init_signal_action(MR_signal_action *act, MR_Code *handler,
>>     MR_bool need_info, MR_bool restart)
>> {
>> Index: runtime/mercury_signal.h
>> ===================================================================
>> RCS file: /home/mercury1/repository/mercury/runtime/mercury_signal.h,v
>> retrieving revision 1.14
>> diff -u -p -b -r1.14 mercury_signal.h
>> --- runtime/mercury_signal.h	20 Jun 2005 02:16:44 -0000	1.14
>> +++ runtime/mercury_signal.h	13 May 2010 03:34:06 -0000
>> @@ -81,6 +81,11 @@ extern	void	MR_setup_signal_no_restart(i
>> 			MR_bool need_info, const char * error_message);
>>
>> /*
>> +** Reset a signal to its default configuration.
>
> s/configuration/handler/

I beleive configuration is more apprprite.  There is no handler associated with
a signal by default, a signal may either kill a process or be ignored by a
process.  This function sets the signal to it's default behaviour, which is
signal dependant, but in all cases no handler is associated with the signal.

I can adjust the comment here to explain this if I like.

>
> That looks okay otherwise.
>

Thanks.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 489 bytes
Desc: Digital signature
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20100518/01b5dea9/attachment.sig>


More information about the reviews mailing list