Skip to content

Commit 238de4e

Browse files
authored
Merge pull request benoitc#2731 from benoitc/daemonize-dev-null-stdin-inheritable
Ensure fd 0 stdin </dev/null is always inheritable Fixed benoitc#2727 .
2 parents e5a9715 + 230cd03 commit 238de4e

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

THANKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ Kyle Mulka <repalviglator@yahoo.com>
109109
Lars Hansson <romabysen@gmail.com>
110110
Leonardo Santagada <santagada@gmail.com>
111111
Levi Gross <levi@levigross.com>
112+
licunlong <shenxiaogll@163.com>
112113
Łukasz Kucharski <lkucharski@leon.pl>
113114
Mahmoud Hashemi <mahmoudrhashemi@gmail.com>
114115
Malthe Borch <mborch@gmail.com>

gunicorn/util.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,10 @@ def daemonize(enable_stdio_inheritance=False):
486486
closerange(0, 3)
487487

488488
fd_null = os.open(REDIRECT_TO, os.O_RDWR)
489+
# PEP 446, make fd for /dev/null inheritable
490+
os.set_inheritable(fd_null, True)
489491

492+
# expect fd_null to be always 0 here, but in-case not ...
490493
if fd_null != 0:
491494
os.dup2(fd_null, 0)
492495

0 commit comments

Comments
 (0)