#1
  1. No Profile Picture
    Dude' Where's My JD and Coke
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Newbury, England
    Posts
    37
    Rep Power
    12

    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.

    Lil' help!

    Thanks in advance
  2. #2
  3. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,171
    Rep Power
    2222
    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.
  4. #3
  5. No Profile Picture
    Dude' Where's My JD and Coke
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Newbury, England
    Posts
    37
    Rep Power
    12
    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
  6. #4
  7. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,171
    Rep Power
    2222
    Originally posted by ice_nin
    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
    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?
  8. #5
  9. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,638
    Rep Power
    4247
    >> 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

IMN logo majestic logo threadwatch logo seochat tools logo