Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CreateProcess intermittently hangs(Win7)

353 views
Skip to first unread message

valery...@gmail.com

unread,
May 4, 2016, 11:11:46 AM5/4/16
to
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

JJ

unread,
May 5, 2016, 2:45:55 AM5/5/16
to
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.

valery...@gmail.com

unread,
May 5, 2016, 3:56:42 AM5/5/16
to
It looks like WaitForInputIdle might be used to sync between parent and child processes, but in my case - CreateProcess does not return from the call and that is the issue. I understand how Unix process creation works, but much less on how it is done on Windows.

So is there anything that might prevent CreateProcess from completion?!

Dawid Bautsch

unread,
May 5, 2016, 8:23:26 AM5/5/16
to
The child process is it a console application or have a GUI ?

valery...@gmail.com

unread,
May 5, 2016, 9:10:01 AM5/5/16
to
On Thursday, May 5, 2016 at 3:23:26 PM UTC+3, Dawid Bautsch wrote:
> The child process is it a console application or have a GUI ?

It is a batch file - script.bat. Normally the event log has entry that this script has been started. When CreateProcess is stuck, no such entry appears in the event log.

JJ

unread,
May 5, 2016, 11:16:26 AM5/5/16
to
On Thu, 5 May 2016 00:56:38 -0700 (PDT), valery...@gmail.com wrote:
>
> It looks like WaitForInputIdle might be used to sync between parent and child processes, but in my case - CreateProcess does not return from the call and that is the issue. I understand how Unix process creation works, but much less on how it is done on Windows.
>
> So is there anything that might prevent CreateProcess from completion?!

If when it stuck in CreateProcess...

1. If the PC case HDD LED doesn't light up, it could be due to buggy anti
virus or anti malware software.

2. If the PC case HDD LED constantly lights up or almost constantly lights
up, it could be a hardware issue.

Big Bad Bob

unread,
May 9, 2016, 6:50:38 PM5/9/16
to
On 05/05/16 06:09, valery...@gmail.com so wittily quipped:
> On Thursday, May 5, 2016 at 3:23:26 PM UTC+3, Dawid Bautsch wrote:
>> The child process is it a console application or have a GUI ?
>
> It is a batch file - script.bat. Normally the event log has entry that this script has been started. When CreateProcess is stuck, no such entry appears in the event log.
>

wait - you're calling 'CreateProcess' on a '.bat' file??? (shouldn't
you run cmd.exe instead, and pass that as a parameter for a script to run?)

If you're trying to invoke something based on file type,
'ShellExecuteEx' might be a better choice.

I've never seen CreateProcess hang, but I only load EXEs with it...

valery...@gmail.com

unread,
May 10, 2016, 5:46:05 AM5/10/16
to
Yes, I am directly invoking '.bat'.
I will try your suggestion with cmd.exe.
0 new messages