Skip to content

Commit

Permalink
Merge pull request #2731 from benoitc/daemonize-dev-null-stdin-inheri…
Browse files Browse the repository at this point in the history
…table

Ensure fd 0 stdin </dev/null is always inheritable

Fixed #2727 .
  • Loading branch information
javabrett committed Feb 6, 2022
2 parents e5a9715 + 230cd03 commit 238de4e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions THANKS
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Kyle Mulka <repalviglator@yahoo.com>
Lars Hansson <romabysen@gmail.com>
Leonardo Santagada <santagada@gmail.com>
Levi Gross <levi@levigross.com>
licunlong <shenxiaogll@163.com>
Łukasz Kucharski <lkucharski@leon.pl>
Mahmoud Hashemi <mahmoudrhashemi@gmail.com>
Malthe Borch <mborch@gmail.com>
Expand Down
3 changes: 3 additions & 0 deletions gunicorn/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,10 @@ def daemonize(enable_stdio_inheritance=False):
closerange(0, 3)

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.dup2(fd_null, 0)

Expand Down

0 comments on commit 238de4e

Please sign in to comment.