that is, to close(0) and open /dev/null as fd=0 instead of fd=3.
(Partially) Revert "Ensure fd 0 stdin </dev/null is always inheritable."
This partially reverts commit 7946678f271e25473618929d6f2725c8c375563e.
When gunicorn --daemon daemonizes the process, prior to this change it was
noted that in the general case (without -R / --enable-stdio-inheritance), when fd 0
was replaced with /dev/null, the dup2 copy is skipped, and per PEP 446
"Make newly created file descriptors non-inheritable", the result was a stdio
fd </dev/null which was non-inheritable. As a result, any launched subprocess
did not have an open 0/stdin fd, which can cause problems in some applications.
This change retains the behaviour of opening /dev/null with fd 0, but adds a call
to os.set_inheritable(..) to ensure the fd is inheritable.
The -R branch had different logic but has now been standardised with the general
case. It was previously opening /dev/null as fd 3 and the dup2() copy made it
inheritable as fd 0. This branch now applies the same logic: open as fd 0
(i.e. after close(0)), then set_inheritable. As a result, an extra fd 3 </dev/null
previously left open is no longer left open.
Signed-off-by: Brett Randall <javabrett@gmail.com>
Noticed by @guettli on GitHub, this sentence was likely supposed to say
that workers may "be killed" and "start up", where "to start up" is a
verb phrase while "startup" is a single word noun. Clarify by changing
this to read "to stop and start".
I was reading the documentation to configure another application successfully deployed with Gunicorn, and thought the documentation here could be improved a bit for clarity.
* Use code highlighting for the names, to indicate they are the names to use in the Python configuration file.
* Spell out the CLI flags and defaults with "Command line" and "Default" prefixes so it's clear what these are
* Consistently use Python syntax for the defaults, so the types may be more easily understood.
* Split multiple CLI flags with "or" rather than a comma, for clarity and easier copy-paste.
* Improve some descriptions, such as for ``raw_env`` and a header for "Server Hooks".