Undo changes that make -R branch logic behave the same as non -R branch,

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.
This commit is contained in:
Brett Randall 2022-01-31 07:26:26 +11:00
parent e9c4f7443e
commit 0b6939de86
No known key found for this signature in database
GPG Key ID: 50EF8B0B7C04B29D

View File

@ -497,17 +497,13 @@ def daemonize(enable_stdio_inheritance=False):
os.dup2(fd_null, 2)
else:
fd_null = os.open(REDIRECT_TO, os.O_RDWR)
# Always redirect stdin to /dev/null as we would
# never expect to need to read interactive input.
os.close(0)
fd_null = os.open(REDIRECT_TO, os.O_RDWR)
# PEP 446, make fd for /dev/null inheritable
os.set_inheritable(fd_null, True)
# expect fd_null to be always 0 here, but in-case not ...
if fd_null != 0:
os.close(0)
os.dup2(fd_null, 0)
# If stdout and stderr are still connected to