celery/celery — pull request #1554 by jalaziz (2013-09-18 14:14:58+00:00)
Title: Don't fork on HUP to preserve PID for process supervisors

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.