1
votes

Parent process launches a child process by invoking CreateProcess() method which returns immediately even before the child process is initialized. How do I make the parent process wait until the Child process got initialized and started executing? WaitForSingleObject() call makes the parent process to wait until the child thread terminates or until timeout.

Is there any similar method which makes the parent process to wait until the child process is intialized?

2
What precisely do you mean by "initialized"?David Schwartz
By Initialized, I mean the child process having started its execution.Vanathi

2 Answers

4
votes

You can create a named event in WinAPI in the parent process and set it to unsignalled state. Call WaitForSingleObject on the event handle. Then in the child process you can open event by name and signal it (call SetEvent()) after the child process is initialized.

-2
votes

If you are using threads, one of the simpliest way to make parent thread wait until the child finishes is using .join() function. In the parent process's end use

child.join();