On Wed, 4 May 2016 08:11:44 -0700 (PDT),
valery...@gmail.com wrote:
> Hello,
>
> I am having an issue that CreateProcess intermittently hangs.
>
> CreateProcess executes a batch file that is located on a local C drive. the application does not wait for the invoked process to complete. It does not use pipe for stdout/stderr redirection etc.
>
> Very simple process invocation, similar to Unix invocation in background.
>
> The application is invoked as follows (relevant snippet):
>
> stat = GetFileAttributes(cmd_str);
> if(0xffffffff == stat)
> {
> return ERROR;
> }
> else
> {
> STARTUPINFO si;
> PROCESS_INFORMATION pi;
>
> memset(&si, 0, sizeof(STARTUPINFO));
> si.cb = sizeof(STARTUPINFO);
> si.dwFlags = STARTF_USESHOWWINDOW;
> si.wShowWindow = SW_HIDE;
>
> ....
> if( !CreateProcess(NULL, cmd_str , NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi) )
> {
> return ERROR;
> }
>
> Sometimes, very rarely, the application seems to be stuck in CreateProcess and never returns from it.
>
> When this happens, Windows event log/audit has no information that process was started.
>
> What might be possible reasons for such behaviour?!
>
> Appreciate any feedback
> Valery
Could be synchronization issue. e.g. child process tries to check parent
process' information.
Try calling WaitForInputIdle() after successful child process creation.