gh-98552: flush std streams in the multiprocessing forkserver before fork (GH-141849)
* flush std streams in the multiprocessing forkserver before fork
* NEWS
(cherry picked from commit
58badb1711e12b6e8b5240ab96cdd01b95012de7)
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
len(fds)))
child_r, child_w, *fds = fds
s.close()
+ util._flush_std_streams()
pid = os.fork()
if pid == 0:
# Child
--- /dev/null
+The :mod:`multiprocessing` forkserver process now flushes stdout and stderr
+before it forks to avoid the confusion children inheriting any buffered but
+not yet written output data. Normally there is none, but when using
+:func:`multiprocessing.set_forkserver_preload` there *could* be.