celery/celery — pull request #1562 by jalaziz (2013-10-03 18:48:00+00:00)
Title: Don't fork on HUP to preserve PID for process supervisors

_Resubmission of #1554 against master_

Some process supervisors (e.g. Upstart) rely on a process maintaining its PID when sending a SIGHUP. If the process forks, the supervisors can lose track of the worker's PID.

Since the execv happens in the atexit handler, the woker should have stopped successfully at that point and, as far as I can tell, an execv is all that is needed.

Also, since the worker won't restart if stdout is connected to a terminal, you have to use output redirection to preserve output logging (unless you specify --logfile). Therefore, we shouldn't be closing the stdout and stderr file descriptors.