]> granicus.if.org Git - python/commitdiff
Fix issue #11432. if the stdin pipe is the same file descriptor as either stdout...
authorGregory P. Smith <greg@krypto.org>
Tue, 15 Mar 2011 18:56:39 +0000 (14:56 -0400)
committerGregory P. Smith <greg@krypto.org>
Tue, 15 Mar 2011 18:56:39 +0000 (14:56 -0400)
in the _posixsubprocess C extension module it would unintentionally close the fds and raise
an error.

Modules/_posixsubprocess.c

index 0f85da97cea341e84e3704dd256cc81e27976a9c..bf10cbb43e13a2c463193d636cb1eaf29b151c54 100644 (file)
@@ -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));
     }