By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,035 Members | 1,384 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,035 IT Pros & Developers. It's quick & easy.

Child Processes of Child Processes

P: 5
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!
Mar 21 '08 #1
Share this Question
Share on Google+
4 Replies


kaarthikeyapreyan
100+
P: 107
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.
Mar 25 '08 #2

P: 5
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.
Mar 27 '08 #3

micmast
100+
P: 144
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).
Mar 27 '08 #4

P: 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.
Mar 27 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.