[MLton-user] signal handlers

Matthew Fluet fluet at tti-c.org
Sat Dec 1 13:25:36 PST 2007


On Sat, 1 Dec 2007, Dave Herman wrote:
> But how do you actually trap them? I can't find the ML analog of signal(...).

It's MLton.Signal.setHandler.  A signal handler is a thread to thread 
function; the argument thread is the (main) thread that was interrupted by 
the arrival of the signal.  The returned thread is the thread you want to 
resume.

If you are doing something relatively simple in the signal handler (like 
setting a few ref cells), then it makes sense to return the argument 
thread.

When building preemptable threads on top of a SIGALRM handler, one would 
enqueue the argument thread and dequeue the return thread from a queue of 
ready threads.

> Wesley W. Terpstra wrote:
>>  On Dec 1, 2007, at 9:29 PM, Dave Herman wrote:
>> >  I couldn't figure out from the MLtonSignal page how to catch signals 
>> >  like SIGWINCH and SIGCONT. Is this possible without resorting to the 
>> >  FFI?
>>
>>  Posix.Signal.cont exists, but I don't think SIGWINCH is readily available.
>>  You can use Posix.Signal.fromWord, but you'd have to know it's numeric
>>  value.
>> 
>
>
> _______________________________________________
> MLton-user mailing list
> MLton-user at mlton.org
> http://mlton.org/mailman/listinfo/mlton-user
>



More information about the MLton-user mailing list