We check if the child process is alive by sending a kill -0 signal to the child. If this method returns without error, then the child is alive and well. Except in the case where the child has terminated by the PID has not yet been reaped by the parent. The simple fix is to wait(WNOHANG) on the child PID beforing checking the state of the child.
A catch block is being used to quickly exit the run loop when needed. This allows your code to respond to stop requests much more easily - simply throw :halt_run_loop. Beware because this will bypass the all the code following the throw call and exit the run loop immediately. The after_stopping block will be run. Example: def run ... throw :halt_run_loop unless running? .. end
Many thanks to Luke Antins for finding this one and sending me a patch. This allows you to figure out which workers have timed out when using the timeout/heartbeat mechanism. Very useful indeed.