I'm using a Java wrapper for a native shared library on Unix (JRI). The native library (a C based REPL implementation for R) handles SIGINT internally. When using the Java wrapper, the Java application quits when I send a SIGINT to the process using:
kill -SIGINT pid
I'd prefer for the SIGINT to be entirely handled by the native library internally.
Is there an easy way to make Java completely ignore a SIGINT but still have the native library receive it?
Addition:
Preferably this would work on Unix and OSX.
There is no standard API for it, but if you are using the Sun JDK, you can use sun.misc.Signal and sun.misc.SignalHandler.
Example from the docs:
SignalHandler handler = new SignalHandler () {
public void handle(Signal sig) {
... // handle SIGINT
}
};
Signal.handle(new Signal("INT"), handler);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With