ditch explicit close command; just close the handle

This commit is contained in:
Glenn Maynard
2006-02-13 23:02:06 +00:00
parent 9eddbde5ac
commit 4b7f50f673
2 changed files with 13 additions and 19 deletions
+12 -17
View File
@@ -247,27 +247,22 @@ void RunChild()
WriteToChild( hToStdin, p, iSize );
/* The parent process needs to access this process briefly. When it's done, it'll
* write a byte to stdout. Wait until we see that before exiting. */
* close the handle. Wait until we see that before exiting. */
while(1)
{
int iCmd;
DWORD iActual;
if( !ReadFile(hFromStdout, &iCmd, sizeof(iCmd), &iActual, NULL) )
break;
/* Ugly: the new process can't execute GetModuleFileName on this process,
* since GetModuleFileNameEx might not be available. Run the requests here. */
if( iCmd == 1 )
{
HMODULE hMod;
ReadFile( hFromStdout, &hMod, sizeof(hMod), &iActual, NULL );
char szName[MAX_PATH];
if( !CrashGetModuleBaseName(hMod, szName) )
strcpy( szName, "???" );
iSize = strlen( szName );
WriteToChild( hToStdin, &iSize, sizeof(iSize) );
WriteToChild( hToStdin, szName, iSize );
}
HMODULE hMod;
DWORD iActual;
if( !ReadFile( hFromStdout, &hMod, sizeof(hMod), &iActual, NULL) )
break;
char szName[MAX_PATH];
if( !CrashGetModuleBaseName(hMod, szName) )
strcpy( szName, "???" );
iSize = strlen( szName );
WriteToChild( hToStdin, &iSize, sizeof(iSize) );
WriteToChild( hToStdin, szName, iSize );
}
}
@@ -784,8 +784,7 @@ void ChildProcess()
DoSave( sCrashReport );
/* Tell the crashing process that it can exit. Be sure to write crashinfo.txt first. */
int iCmd = 0;
write( _fileno(stdout), &iCmd, sizeof(iCmd) );
fclose( stdout );
/* Now that we've done that, the process is gone. Don't use g_hParent. */
CloseHandle( SymbolLookup::g_hParent );