I am writing a program for a producer-consumer problem.
Producer produces data and pushes data into boost::spsc_queue
and the consumer processes it.
In consumer thread, I am using JNI
to call some java functions from my code written in c++.
I am initializing and creating JVM
in the function itself called by the consumer thread and then the event loop starts in which it pops data from boost::spsc_queue
and process it.
Now, I want to catch SIGINT
signal, so I have written a signal_handler
and register it in my main()
function. But it is not working.
If I comment out all JNI stuff and just start a loop while(1){}
there in the function called by consumer thread, then it is catching SIGINT and working as it is supposed to work.
Is something more which I need to take care for JVM or JNI stuff? Shall I try the same thing after initializing and creating JVM in the main thread? Does it make sense?