[MLton] cvs commit: better blocking/unblocking of signals in runtime

Matthew Fluet fluet@cs.cornell.edu
Sun, 28 Mar 2004 20:23:31 -0500 (EST)


>   It may not be the right behavior for GC_{start,finish}Handler.  The
>   problem is that between GC_startHandler and GC_finishHandler, the SML
>   signal handler is run.  If the handler calls
>   MLton.Signal.Mask.setBlocked, then this change will be lost when
>   GC_finishHandler is invoked.  Unfortunately, I suspect that blocking
>   signals is one thing you might want to do in the signal handler.

The right thing to do would be in runtime/Posix/Signal.c:

Int Posix_Signal_sigprocmask (Int how) {
	if (gcState.inSignalHandler) {
		/* Change gcState.signalsBlocked appropriately,
		 * so that they are restored at GC_finishHandler.
		 * Don't change the actual signal mask.
		 */
		return 1;
	}
	return sigprocmask (how, &set, (sigset_t*)NULL);
}

Unfortunately, Posix doesn't seem to give you a way of doing that.  I can
do it with some GNU extensions:
/* Build new signal set by combining the two inputs set using logical AND.
*/
extern int sigandset (sigset_t *__set, __const sigset_t *__left,
                      __const sigset_t *__right) __THROW;

/* Build new signal set by combining the two inputs set using logical OR.
*/
extern int sigorset (sigset_t *__set, __const sigset_t *__left,
                     __const sigset_t *__right) __THROW;