(sun.misc.Signal/handle
(sun.misc.Signal. "INT")
(proxy [sun.misc.SignalHandler] []
(handle [sig] (throw (Exception. (str sig))))))
...except that's actually worse (at least for this platform and
version of Java) as it is catches the Ctrl-C (preventing the Repl from
dying) but then process it in its own thread, allowing all other
threads (notably the one we're trying to stop) to continue.
Which helps focus the question -- which exact threads should be
stopped by Ctrl-C? Just the Repl's thread I suppose?
--Chouser
> Which helps focus the question -- which exact threads should be
> stopped by Ctrl-C? Just the Repl's thread I suppose?
>
I think you'd somehow want to interrupt the call to:
75: Object ret = Compiler.eval(r);
in Repl.java. Not sure if this can be done though, as I don't see any
way to interrupt the execution of this thread. You could potentially
try destroy()ing (although the 1.4 docs say this is unimplemented) the
Repl and then launching a new thread to start it again.
If Thread.destroy() works, you might be able to get ok results by
re-architecting Repl.java to launch the call to Compiler.eval() in a
new thread, and then the signal handler would just call
Thread.destroy() to kill the runaway evaluation.
Who knows how this actually behaves though.
There might be some APIs that would help with this, but my suspicion
is that doing this reliably would not be trivial.
/mike.