|
|
@@ -280,7 +280,11 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
|
|
|
{
|
|
|
startupInfo.hStdInput = 0;
|
|
|
}
|
|
|
- if (options & PROCESS_CLOSE_STDIN) CloseHandle(GetStdHandle(STD_INPUT_HANDLE));
|
|
|
+ if (options & PROCESS_CLOSE_STDIN)
|
|
|
+ {
|
|
|
+ HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
|
|
|
+ if (hStdIn) CloseHandle(hStdIn);
|
|
|
+ }
|
|
|
|
|
|
// outPipe may be the same as errPipe, so we duplicate first and close later.
|
|
|
if (outPipe)
|
|
|
@@ -312,9 +316,17 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
|
|
|
startupInfo.hStdError = 0;
|
|
|
}
|
|
|
if (outPipe) outPipe->close(Pipe::CLOSE_WRITE);
|
|
|
- if (options & PROCESS_CLOSE_STDOUT) CloseHandle(GetStdHandle(STD_OUTPUT_HANDLE));
|
|
|
+ if (options & PROCESS_CLOSE_STDOUT)
|
|
|
+ {
|
|
|
+ HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
|
+ if (hStdOut) CloseHandle(hStdOut);
|
|
|
+ }
|
|
|
if (errPipe) errPipe->close(Pipe::CLOSE_WRITE);
|
|
|
- if (options & PROCESS_CLOSE_STDERR) CloseHandle(GetStdHandle(STD_ERROR_HANDLE));
|
|
|
+ if (options & PROCESS_CLOSE_STDERR)
|
|
|
+ {
|
|
|
+ HANDLE hStdErr = GetStdHandle(STD_ERROR_HANDLE);
|
|
|
+ if (hStdErr) CloseHandle(hStdErr);
|
|
|
+ }
|
|
|
|
|
|
if (mustInheritHandles)
|
|
|
{
|