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

Matthew Fluet fluet@cs.cornell.edu
Thu, 15 Apr 2004 08:20:35 -0400 (EDT)


> >  static inline void blockSignals (GC_state s) {
> >  	if (shouldBlockSignals ())
> > -		sigprocmask (SIG_BLOCK, &s->signalsHandled, &s->signalsBlocked);
> > +		sigprocmask (SIG_BLOCK, &s->signalsHandled, NULL);
> >  }
>
> I guess it doesn't matter, but SIG_SETMASK might be clearer here.

No, because SIG_SETMASK installs exactly &s->signalsHandled, which may not
include everything that is blocked.  I.e., I can block a signal without
having a signal handler, and I don't way to receive the signal (and kill
the process) just because the signal arrives while execution is in the
runtime.

> > +Int Posix_Signal_sigprocmask () {
> > +	gcState.signalsBlocked = set;
> > +	if (gcState.inSignalHandler)
> > +		return 1;
> > +	return sigprocmask (SIG_SETMASK, &set, (sigset_t*)NULL);
>
> I don't understand why 1 is returned if gcState.inSignalHandler.
> sigprocmask is supposed to return 0 on success and -1 on error.  We
> could try to figure out what it should mean to block/unblock signals
> while running a handler -- until we figure this out, we could raise an
> exception if someone tries to do so.

I meant for it to return success, so it should return 0.