Signal Handling in Java

It is not well documented, nor is it officially supported, but Sun (and others) include a signal handling mechanism with their JVMs which can be accessed by java code. The classes of interest are sun.misc.Signal and sun.misc.SignalHandler. I'm not going to reproduce the source or documentation here because of licensing restrictions, however you can download the full source yourself at this url:

I have written a small set of classes which make it a little easier to take advantage of this functionality. You can use them in your own code, or just look at the source to get a better idea of how the sun.misc.Signal* classes work:

See SignalLogger for an example use.

home | hacks | contact