mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
[3.13] gh-135335: flush stdout/stderr in forkserver after preloading modules (GH-135338) (#135671)
gh-135335: flush stdout/stderr in forkserver after preloading modules (GH-135338)
If a preloaded module writes to stdout or stderr, and the stream is buffered,
child processes will inherit the buffered data after forking. Attempt to
prevent this by flushing the streams after preload.
(cherry picked from commit 9877d191f4
)
Co-authored-by: Duane Griffin <duaneg@dghda.com>
Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
28a70a59e4
commit
a0a1aa3125
4 changed files with 50 additions and 0 deletions
|
@ -182,6 +182,10 @@ def main(listener_fd, alive_r, preload, main_path=None, sys_path=None):
|
|||
except ImportError:
|
||||
pass
|
||||
|
||||
# gh-135335: flush stdout/stderr in case any of the preloaded modules
|
||||
# wrote to them, otherwise children might inherit buffered data
|
||||
util._flush_std_streams()
|
||||
|
||||
util._close_stdin()
|
||||
|
||||
sig_r, sig_w = os.pipe()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue