[MLton] cvs commit: Added PosixError.SysCall structure.

Stephen Weeks MLton@mlton.org
Thu, 29 Apr 2004 23:29:36 -0700


>   There is a little bit of an ordering problem; in that SysCall.syscall
>   wants access to MLton.Signal.Mask to block and unblock signals when in
>   a critical section; on the other hand, MLton.Signal needs a lot of
>   infrastructure to be implemented. 

I was thinking that maybe you could split out MLton.Signal.Mask from
the rest of MLton.Signal, and move it before the definition of
PosixError.  But I see that the blocker needs to refer to the array of
handlers and hence drags in a lot of MLton.Signal.  So I don't see any
way out.  One problem that might result is if a signal interrupts a
system call that is part of basis library initialization, before
MLton.Signal has been set up.  It might be better to have the blocker
simply return, rather than raise an error in this case.

I'm more worried that the assignment to blocker in MLton.Signal is
going to drag in signal handling code into every program, whether or
not it installs handlers.  To avoid this, I think Mask.handled and the
assignment to blocker need to be moved into the let that defines
(getHandler, setHandler, handlers).

One thing I've forgotten from our many discussions last month is why,
when we are in a critical section and need to restart a system call,
do we only block the signals handled by SML?  It would seem a better
guarantee of progress to block all signals.  It would also remove the
dependency of syscall on the signal handling infrastructure, perhaps
making it possible to split out Signal.Mask.  But I must be forgetting
something :-(.

BTW, another thing I noticed is that syscall is only restarting if the
error is EINTR.  I think EAGAIN should also cause a restart.