Handle SIGCHLD using a self-pipe trick, factor out a child handler method

The previous code would wait until the next loop tick to handle an ungraceful
child exit. This refactoring handles the child exit immediately.