alternate stacks for signal handlers

Stephen Weeks MLton@sourcelight.com
Wed, 26 Jul 2000 17:34:34 -0700 (PDT)


> Next,  in  every  call to sigaction you should set the sa_flags member of the
> struct sigaction to
>     SA_RESTART | SA_ONSTACK
> The SA_RESTART makes sure that any system call going on when  the  signal  is
> delivered  will be restarted (instead of returning failure with errno EINTR).
> The SA_ONSTACK is the flag that says to use the signal stack.

I've been playing around with using itimers to do timeouts, and I
think there is a problem if we use SA_RESTART.  Suppose we have an SML 
program that installs an SML signal handler for Posix.Signal.usr1 and
then makes a call to Posix.IO.readVec, which blocks at the read system 
call.  If a SIGUSR1 arrives, then the C runtime system handler will
run, setting the limit so that at the next limit check the SML handler
will run, and then terminate.  The system call will then restart and
block.

So, it looks like to me that the SML signal handler will never get a
chance to run.  This seems wrong.