This is a follow up question to this one.
Take this simple example:
public class Main
{
public static void main(String[] args) throws Exception
{
Runtime.getRuntime().exec("./child");
// This is just so that the JVM does not exit
Thread.sleep(1000 * 1000);
}
}
And here's the child process:
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
void handle_sigquit(int sig) {
printf("Signal %d received\n", sig);
exit(1);
}
int main(int argc, char **argv) {
signal(SIGQUIT, &handle_sigquit);
sleep(1000);
}
As you can see, I am explicitly setting up a signal handler in the child process.
When I run this process from a shell, I can send it a SIGQUIT
; the signal is received and processed properly. However if I start the process from Java (I am using openjdk6 on Linux) the signal is not delivered. Why is this?