I have a C++ qt application that makes few out-of-process calls through QProcess. I'm trying to make a call to a java class through JNI (copied from https://stackoverflow.com/a/992876/3505471 with no changes except adding classpath).
The JNI call works fine. But any QProcess invocations after a call to env->CallStaticVoidMethod()
gets stuck at qprocess->waitForFinished()
. The qprocess seems to have completed its task (which I infer from the output log), but I believe it has failed to inform the parent process that it has completed.
Digging further, I find that SIGCHLD
is supposed to be sent to the parent process when a child process exits. I also find that JVM also uses signals to communicate (I'm fairly new to JNI and signal handling) and possibly trapping SIGCHLD(?)
How do I configure the JVM to not interfere with these signals or is there a better way for them to co-exist? I would also appreciate if you can help me understand what happens under the hood w.r.t. signals in JVM.
In retrospect, I found some logs which I foolishly ignored during the start and probably an important piece in this puzzle.
Warning: SIGPIPE handler expected:libjvm.dylib+0x5fbe5c found:0x0000000000000001
Signal Handlers:
SIGSEGV: [libjvm.dylib+0x5fbe5c], sa_mask[0]=11111111011111110111111111111111, sa_flags=SA_ONSTACK|SA_RESTART|SA_SIGINFO
SIGBUS: [libjvm.dylib+0x5fbe5c], sa_mask[0]=11111111011111110111111111111111, sa_flags=SA_RESTART|SA_SIGINFO
SIGFPE: [libjvm.dylib+0x5fbe5c], sa_mask[0]=11111111011111110111111111111111, sa_flags=SA_RESTART|SA_SIGINFO
SIGPIPE: SIG_IGN, sa_mask[0]=00000000000000000000000000000000, sa_flags=none
SIGXFSZ: [libjvm.dylib+0x5fbe5c], sa_mask[0]=11111111011111110111111111111111, sa_flags=SA_RESTART|SA_SIGINFO
SIGILL: [libjvm.dylib+0x5fbe5c], sa_mask[0]=11111111011111110111111111111111, sa_flags=SA_RESTART|SA_SIGINFO
SIGUSR2: [libjvm.dylib+0x5fc45a], sa_mask[0]=00000000000000000000000000000000, sa_flags=SA_RESTART|SA_SIGINFO
SIGHUP: SIG_DFL, sa_mask[0]=00000000000000000000000000000000, sa_flags=none
SIGINT: SIG_DFL, sa_mask[0]=00000000000000000000000000000000, sa_flags=none
SIGTERM: SIG_DFL, sa_mask[0]=00000000000000000000000000000000, sa_flags=none
SIGQUIT: SIG_DFL, sa_mask[0]=00000000000000000000000000000000, sa_flags=none
More context: I will be needing JVM to exist throughout the lifetime of my application (initialize once and call methods when needed for better performance), so I've made it a member of a singleton class. I have to make out-of-process calls before and after the JNI calls. I have to get this working on mac and windows (currently testing on mac).