-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
skip close_on_exec() #3713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
skip close_on_exec() #3713
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,17 +106,9 @@ def init_process(self): | |
| self.PIPE = os.pipe() | ||
| for p in self.PIPE: | ||
| util.set_non_blocking(p) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When application code forks and execs a child without closing file descriptors (for example, Useful? React with 👍 / 👎.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Arbitor of gunicorn uses os.fork() instead of Popen(). When creating self.LISTENERS, it is not set to inheritable, so it remains non-inheritable from the parent process. It is not necessary to set it after forking in the child process. |
||
| util.close_on_exec(p) | ||
|
|
||
| # Prevent fd inheritance | ||
| for s in self.sockets: | ||
| util.close_on_exec(s) | ||
| util.close_on_exec(self.tmp.fileno()) | ||
|
|
||
| self.wait_fds = self.sockets + [self.PIPE[0]] | ||
|
|
||
| self.log.close_on_exec() | ||
|
|
||
| self.init_signals() | ||
|
|
||
| # start the reloader | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
--logger-classsupplies a custom logger whoseclose_on_exec()handles inherited or explicitly inheritable logging descriptors, this removal silently stops invoking that hook in both the master and workers. PEP 446 only changes defaults for descriptors created by Python and cannot replace custom cleanup logic, so those descriptors can leak through a master re-exec or an exec launched by application code; retain the lifecycle call even if the built-in logger implementation no longer needs to do work.Useful? React with 👍 / 👎.