September 22nd, 2003, 05:37 AM
Enum Child Processes
Does anyone out there know how I can monitor any child processes created by an application that I launch. I need to wait for all child processes complete before i continue any processing in the main application.
Thanks in advance
September 22nd, 2003, 10:55 AM
Basically, I would think saving each child PID when you fork (after the fork, that's how you can tell that you're the parent) and then checking each one off as it completes, as reported to you by waitpid. Since wait and waitpid also give you the child's exit status, you can also check whether they had all completed successfully.
September 22nd, 2003, 11:07 AM
The problem is that the child process itself can spawn its own child processes. Anyone knows if they can be tracked as well.
P.S. I am working on WindowXP, I noticed that you were forking all over the place in the last reply. Dont think that it matters but I thought I should let you know what platform i was on
September 22nd, 2003, 01:03 PM
It certainly is a good idea to state up front what your platform is, especially since process spawning is very platform-dependent.
OK, put each child process in charge of the child processes that it spawns. Then have each process wait until its own children have completed (I assume that is part of the requirement) and have its exit status reflect whether its children all completed successfully or not (I assume that Windows' version of wait/waitpid or some other mechanism gives you that capability). The final level will be the original parent.
Is this doable in XP?
September 22nd, 2003, 01:10 PM
>> I need to wait for all child processes complete before i continue any processing in the main application.
You can try using the WaitForMultipleObjects() API call.
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
"I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo