mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 10:32:57 +01:00
fix(Process): CloseHandle() on an null/invalid handle will throw an exception in the debugger
This commit is contained in:
parent
e428c4b46c
commit
a25cdac549
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user