ddollar/foreman — pull request #428 by beeblebrox (2014-02-03 00:32:09+00:00)
Title: Exec process, otherwise only the shell receives signal.

I found an issue by having a Procfile with an invalid command and then a valid executable. If I did foreman start it would bail, as expected. However what wasn't expected was the valid command's signal handlers were never called and the process was left running. What was also interesting, if I ran with a valid procfile, and forced shutdown on one process, the other exectuable with a signal handler's process would be removed but again it didn't appear the signal handler was called.

I traced this to the Process.spawn running the 'shell' version of spawn. I think it has to do this to change the environment, but it means that the shell raps the Foreman runner in a child process. This means the signals being sent to the process by Foreman are swallowed by the shell and never sent to the foreman runner process (which does exec the original command).

I added exec to the front of the wrapped command. This fixes my issue, I am unsure how portable this is for various shells. Perhaps someone can improve this.