Running programs under a python program...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • samslists@gmail.com

    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.Pope n(command_line, shell=True, stdout=fd,
    stderr=subproce ss.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!
  • inhahe

    #2
    Re: Running programs under a python program...

    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.ST DOUT, 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

    <samslists@gmai l.comwrote in message
    news:43c19b29-878a-41b8-b2c9-48b5d91233c3@t1 2g2000prg.googl egroups.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.Pope n(command_line, shell=True, stdout=fd,
    stderr=subproce ss.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!

    Comment

    • Matthew Woodcraft

      #3
      Re: Running programs under a python program...

      samslists@gmail .com <samslists@gmai l.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.Pope n(command_line, shell=True, stdout=fd,
      stderr=subproce ss.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-

      Comment

      Working...