ddollar/foreman — pull request #137 by tjdett (2012-01-20 08:02:54+00:00)
Title: Upstart explicit SIGTERM to children

The Upstart scripts generated by Foreman don't always kill the running process, because they rely on children dying when the parent exits.

This patch does two things:

1. It introduces a `$` for all process executions. According to the [Upstart documentation](http://upstart.ubuntu.com/getting-started.html) for `exec`:

> any special characters (e.g. quotes or ‘$’) will result in the command being passed to a shell for interpretation

As a result, all processes will be wrapped by bash (not just the ones using `$PORT`).

2. It traps the bash script exit, and generates a `SIGTERM` to all processes in the process group.

I've tested this fix with [uWSGI](http://projects.unbit.it/uwsgi/) (inside a wrapper to handle uWSGI's [interesting interpretation of SIGKILL](http://projects.unbit.it/uwsgi/wiki/uWSGISignals)) and it works well.