Child Processes of Child Processes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ldb88
    New Member
    • Feb 2008
    • 5

    #1

    Child Processes of Child Processes

    My python script launches program A. Program A launches program B. Program A closes without waiting for program B to complete. How can I know when program B completes?

    This is on a Windows XP machine. Thanks!
  • kaarthikeyapreyan
    New Member
    • Apr 2007
    • 106

    #2
    Originally posted by ldb88
    My python script launches program A. Program A launches program B. Program A closes without waiting for program B to complete. How can I know when program B completes?

    This is on a Windows XP machine. Thanks!
    The script that launches the program A is the parent of program and A launches another program B which is the grandchild of the main script. I believe that since that A launches B the process for A is still on the run,if A terminates then B must also terminate unless its launched as a orphan process or a daemon process. B returns a exit status to its parent A stating that its job is done. we can catch the exit status of the program once its completed or to know that its successfully completed.

    Comment

    • ldb88
      New Member
      • Feb 2008
      • 5

      #3
      Thanks for replying.

      I'm not sure how program A launches program B, but I managed to find a way to get the pid of process B.

      The only problem is that os.waitpid(pid, 0) doesn't work. It says no child process, but in the documentation I see that any pid should work, whether it is a child or not.

      Is there something special I have to do with the pid for it to work? The pid I am using is the one that the Task Manager shows.

      Thanks.

      Comment

      • micmast
        New Member
        • Mar 2008
        • 144

        #4
        I don't know how the code looks, but you might want to consider using popen, that contains a pid for the child processes. Also the program can wait for the program to finish before continuing it's execution (termination).

        Comment

        • ldb88
          New Member
          • Feb 2008
          • 5

          #5
          I'm been running this from Cygwin, but giving it the Windows pid. Is there a way to specify that I want to wait for a Windows pid without having to exit Cygwin, reopen, and then continuing?

          EDIT: Actually, that won't work either. I can't wait for a pid whether I go through cygwin or cmd.exe.

          Comment

          Working...