From 66c9cb9f8ce1f4f8064dce7b57a0c1de9d07df32 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 1 Aug 2002 00:14:47 +0000 Subject: [PATCH] clean up better when exec fails --- dtool/src/dtoolutil/pfstreamBuf.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dtool/src/dtoolutil/pfstreamBuf.cxx b/dtool/src/dtoolutil/pfstreamBuf.cxx index cef6414f58..a16d8cb07b 100644 --- a/dtool/src/dtoolutil/pfstreamBuf.cxx +++ b/dtool/src/dtoolutil/pfstreamBuf.cxx @@ -343,6 +343,8 @@ open_pipe(const string &cmd) { #ifndef NDEBUG cerr << "Unable to redirect stdout\n"; #endif + CloseHandle(hChildStdoutRd); + CloseHandle(hChildStdoutWr); return false; } @@ -357,6 +359,8 @@ open_pipe(const string &cmd) { #ifndef NDEBUG cerr << "DuplicateHandle failed\n"; #endif + CloseHandle(hChildStdoutRd); + CloseHandle(hChildStdoutWr); return false; } CloseHandle(hChildStdoutRd); @@ -377,7 +381,7 @@ open_pipe(const string &cmd) { cerr << "Unable to spawn process.\n"; #endif close_pipe(); - return false; + // Don't return yet, since we still need to clean up. } delete[] cmdline; @@ -387,8 +391,6 @@ open_pipe(const string &cmd) { #ifndef NDEBUG cerr << "Unable to restore stdout\n"; #endif - close_pipe(); - return false; } // Close the write end of the pipe before reading from the @@ -397,11 +399,9 @@ open_pipe(const string &cmd) { #ifndef NDEBUG cerr << "Unable to close write end of pipe\n"; #endif - close_pipe(); - return false; } - return true; + return (_child_out != 0); } ////////////////////////////////////////////////////////////////////