From: Gregory P. Smith Date: Tue, 15 Mar 2011 18:56:39 +0000 (-0400) Subject: Fix issue #11432. if the stdin pipe is the same file descriptor as either stdout... X-Git-Tag: v3.2.1b1~295 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9c4f44f70acadd70fcdb0a0d5d66cefbc9da20bf;p=python Fix issue #11432. if the stdin pipe is the same file descriptor as either stdout or stderr in the _posixsubprocess C extension module it would unintentionally close the fds and raise an error. --- diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c index 0f85da97ce..bf10cbb43e 100644 --- a/Modules/_posixsubprocess.c +++ b/Modules/_posixsubprocess.c @@ -99,10 +99,10 @@ static void child_exec(char *const exec_array[], if (p2cread > 2) { POSIX_CALL(close(p2cread)); } - if (c2pwrite > 2) { + if (c2pwrite > 2 && c2pwrite != p2cread) { POSIX_CALL(close(c2pwrite)); } - if (errwrite != c2pwrite && errwrite > 2) { + if (errwrite != c2pwrite && errwrite != p2cread && errwrite > 2) { POSIX_CALL(close(errwrite)); }