Your problem is that SIGINT is an asynchronous signal; this can happen between any two machine instructions if they are not locked.
This means that it is not safe to call anything other than asynchronous functions from your signal handler (and, if you want to be portable, you should not do anything other than set the sig_atomic_t variables). The JVM is certainly not considered asynchronous. Most likely, you interrupt the JVM in the middle of some important code, and your method call distorts the state of the JVM.
The approach commonly used to process SIGINT is to have a loop somewhere where the flag variable (such as sig_atomic_t ) is checked. When you get SIGINT , set the flag and return it. The loop will appear and execute the rest of the handler in a safe, synchronous manner.
In your case, you can simply create a Java thread that periodically calls the checkForInterrupt function, which checks the aforementioned flag variable. checkForInterrupt returns the current status of the flag, and then your thread can act on it.
Another option is to use a function like pause , sigwait or sigsuspend to pause the stream until a signal is received. Then the stream wakes up and processes the signal synchronously.
source share