George Russell writes:
> I can't get Posix.installHandler to do what I expect it to
> do. Attached is a sample program.
> If my reading of the documentation is correct, this should
> prompt with ">0" for a reply
> repeatedly until the user interrupts, after which it replaces
> the current continuation with
> the supplied handler, thus printing out "Interrupted!", and
> continuing to prompt with "1>".
> And so on. Following is a sample trace (Sparc/Solaris as
> always). Note (1) just before
> ^C an extra input line seems to get inserted. (2) Somehow
> the supplied handler doesn't
> keep going, instead we return to the old continuation, for no
> reason I can see.
> What is going on?
I'm not sure which documentation you're reading, but it looks out of date.
The signal-handling semantics in 4.04 are (quoting from the User's Guide, in
the Posix library section):
"if handler is Catch action, a handler is installed which
will invoke action in a new thread when (or shortly after)
the signal is received"
So the handler is given a new thread all to itself, and the main thread
carries on running as normal. If you want the old semantics, you can
arrange to raise an exception in the main thread, or something similar.
Cheers,
Simon