Fix dangling pipe: we didn't close the child's ends of

the pipes in the parent, so it kept a reference to the
handles.  (This didn't cause problems normally, but since
the child's ends of the pipes remained open when it closed,
it reduced reliability in failure cases.)
This commit is contained in:
Glenn Maynard
2006-02-12 04:57:13 +00:00
parent b491a6d702
commit e6ae006f60
+11 -2
View File
@@ -122,7 +122,7 @@ bool StartChild( HANDLE &hProcess, HANDLE &hToStdin, HANDLE &hFromStdout )
strcat( szBuf, CHILD_MAGIC_PARAMETER );
PROCESS_INFORMATION pi;
if( !CreateProcess(
int iRet = CreateProcess(
NULL, // pointer to name of executable module
szBuf, // pointer to command line string
NULL, // process security attributes
@@ -133,8 +133,17 @@ bool StartChild( HANDLE &hProcess, HANDLE &hToStdin, HANDLE &hFromStdout )
cwd, // pointer to current directory name
&si, // pointer to STARTUPINFO
&pi // pointer to PROCESS_INFORMATION
) )
);
CloseHandle( si.hStdInput );
CloseHandle( si.hStdOutput );
if( !iRet )
{
CloseHandle( hToStdin );
CloseHandle( hFromStdout );
return false;
}
hProcess = pi.hProcess;