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

Julien Fischer juliensf at csse.unimelb.edu.au
Tue May 18 01:06:30 AEST 2010


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/

> +*/
> +extern  void    MR_reset_signal(int sig);
> +
> +/*

That looks okay otherwise.

Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list