nodejitsu/forever-monitor — pull request #56 by airandfingers (2014-02-17 05:30:02+00:00)
Title: Make kill wait for child process to exit, to add support for asynchronous signal handlers

As discussed at https://github.com/nodejitsu/forever/issues/528, forever-monitor's common.kill function immediately calls its callback, whether or not the killed process has exited. My process has an asynchronous handler for kill signals like SIGTERM, but when I told forever to stop my process (with killSignal=SIGTERM), this handler was not allowed to finish, and its output to the log file was truncated.

This change makes Monitor's kill function wait for the child process to exit, and passes a no-op function into common.kill.

Note: this change works for my purposes, but it doesn't handle complexities as discussed by @andreyst, including killTTL, killTree, and signals that are not intended to cause the child process to exit.