I have a Java process, that (re)starts a Linux process, which spawns two daemonised child processes and dies. (It's a wrapper to HAProxy, which is configured as a daemon with 2 Processes)
On every re-start, the process table has two more Zombie processes. To prevent these Zombies, I have implemented the following:
final static SignalHandler _signalHandler = new SignalHandler() {
@Override
public void handle(Signal signal) {
LOG.info("Received signal: {}",signal.getName());
}
};
public HaproxyWrapper() {
Signal.handle(new Signal("CHLD"), _signalHandler);
LOG.info("Registered SIGCHLD signal handler");
}
I see the 'Registered SIGCHLD' log in the output, but never the 'Received signal: SIGCHLD'.
Am I doing this wrong?
Alternatively, 'the simplest thing that could possibly work' - I could create a shell script called start_haproxy.sh which will both call haproxy and handle the SIGCHLD. How do I handle SIGCHLD in bash? (handle -> ignore)
Thanks.