title: Handling SIGCHLD signal in Java
body: <p>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)</p>
  
  <p>On every re-start, the process table has two more Zombie processes.
  To prevent these Zombies, I have implemented the following:</p>
  
  <pre><code>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");
  }
  </code></pre>
  
  <p>I see the 'Registered SIGCHLD' log in the output, but never the 'Received signal: SIGCHLD'.</p>
  
  <p>Am I doing this wrong?</p>
  
  <p>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)</p>
  
  <p>Thanks.</p>