469,275 Members | 1,619 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

Running programs under a python program...

So I have a python program that runs a bunch of other programs....it
then loops forever, occasionally executing other programs.

To run each of these programs my python code executes:
subprocess.Popen(command_line, shell=True, stdout=fd,
stderr=subprocess.STDOUT)

where command_line is an appropriate command line. :)

Now my problem is when I abort this program it kills off all the child
processes I've started. In this case I don't want that. How can I
stop the child processes from dieing when I kill off the parent?

Thanks!
Jun 27 '08 #1
2 1060
maybe you could instead of killing the program stop the loop that starts
new processes and start one that runs until the last process ends?

also, if you killed the program but stdout was still set to fd and stderr
was still set to subprocesses.STDOUT, what would happen when those two
objects disappeared? wouldn't the processes crash or something?

i dunno much about this though, maybe there's some way

<sa*******@gmail.comwrote in message
news:43**********************************@t12g2000 prg.googlegroups.com...
So I have a python program that runs a bunch of other programs....it
then loops forever, occasionally executing other programs.

To run each of these programs my python code executes:
subprocess.Popen(command_line, shell=True, stdout=fd,
stderr=subprocess.STDOUT)

where command_line is an appropriate command line. :)

Now my problem is when I abort this program it kills off all the child
processes I've started. In this case I don't want that. How can I
stop the child processes from dieing when I kill off the parent?

Thanks!

Jun 27 '08 #2
sa*******@gmail.com <sa*******@gmail.comwrote:
So I have a python program that runs a bunch of other programs....it
then loops forever, occasionally executing other programs.

To run each of these programs my python code executes:
subprocess.Popen(command_line, shell=True, stdout=fd,
stderr=subprocess.STDOUT)

where command_line is an appropriate command line. :)

Now my problem is when I abort this program it kills off all the child
processes I've started. In this case I don't want that. How can I
stop the child processes from dieing when I kill off the parent?
It depends on why the children are dying.

From what you say, it seems likely that they're trying to write to
their standard output, and exiting because that's a pipe that is now
closed.

If that's the case, it's probably best to start by deciding where you
want that output to go when the parent process has ended. Perhaps you
can just send it all to a log file in the first place.

-M-

Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Colin Brown | last post: by
9 posts views Thread by Matt Helm | last post: by
3 posts views Thread by James Stroud | last post: by
13 posts views Thread by John Salerno | last post: by
20 posts views Thread by Guy Fawkes | last post: by
3 posts views Thread by Josh Volz | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.