Akira Li added the comment: Josh, on Windows, if at least one standard stream is replaced; all three hStdInput, hStdOutput, hStdError handles are provided (all-or-nothing). On POSIX, standard streams stdin (0), stdout (1), stderr (2) are always inherited from the parent. Each stream can be manipulated independently. c2pwrite=-1 is different from providing c2pwrite=1 (STDOUT_FILENO) explicitly e.g., set_inheritable() call is made after the fork() in the latter case.
My patch leads to dup2(fileno(stdout), STDERR_FILENO) when stdout is None and stderr=STDOUT on POSIX i.e., it redirects stderr to the inherited stdout (like 2>&1 in the shell). It has no effect otherwise. sys.__stdout__ is used so that the call fails sooner without fork() if fileno(stdout) is not a valid file descriptor when python initializes (daemon, GUI). __stdout__-based solution doesn't support a case when fileno(stdout) is changed later in the program e.g., using freopen() on some systems. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue22274> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com