Create Process + WaitForSingleObject hangs
-
Hi, I have a problem with WaitForSingleObject. my code are as follows int RunExternalProES(LPTSTR ExecProc, int option) { STARTUPINFO si; PROCESS_INFORMATION pi; DWORD pProcessID; ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); // Start the child process. if( !CreateProcess(NULL, // No module name (use command line). ExecProc, // Command line. NULL, // Process handle not inheritable. NULL, // Thread handle not inheritable. TRUE, // Set handle inheritance to FALSE. 0, // No creation flags. NULL, // Use parent's environment block. NULL, // Use parent's starting directory. &si, // Pointer to STARTUPINFO structure. &pi ) // Pointer to PROCESS_INFORMATION structure. ) { return FALSE; //( "CreateProcess failed." ); } if (option == 1) { WaitForSingleObject(pi.hProcess, INFINITE); } } i found that sometime waitforsingleobject function will hang for some process.. is there any reson why this happens? Thanks
-
Hi, I have a problem with WaitForSingleObject. my code are as follows int RunExternalProES(LPTSTR ExecProc, int option) { STARTUPINFO si; PROCESS_INFORMATION pi; DWORD pProcessID; ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); // Start the child process. if( !CreateProcess(NULL, // No module name (use command line). ExecProc, // Command line. NULL, // Process handle not inheritable. NULL, // Thread handle not inheritable. TRUE, // Set handle inheritance to FALSE. 0, // No creation flags. NULL, // Use parent's environment block. NULL, // Use parent's starting directory. &si, // Pointer to STARTUPINFO structure. &pi ) // Pointer to PROCESS_INFORMATION structure. ) { return FALSE; //( "CreateProcess failed." ); } if (option == 1) { WaitForSingleObject(pi.hProcess, INFINITE); } } i found that sometime waitforsingleobject function will hang for some process.. is there any reson why this happens? Thanks
-
The process that spawns the new process has limited knowledge of what goes on afterward. If WaitForSingleObject() does not return for a long time then I suspect that the spawned process is not exiting. Kuphryn
kuphryn wrote: I suspect that the spawned process is not exiting. Yes, that would be my assumption as well
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"