| |
comp.lang.python |
Den Tue, 05 Jun 2007 14:07:44 +0200 skrev Stefan Sonnenberg-Carstens: >> from subprocess import Popen >> start it and kill it, the ping process lives on. Is there a way to > Calling popen.close() perhaps ?
>> Hi, When I do a small program like
>> popen = Popen(["ping", "google.com"]) from time import sleep
>> sleep(100)
>> ensure that the ping process is always killed when the python process
>> is?
>> I can't use atexit, as ping then isn't killed when python is killed "in
>> the hard way"
> You basically open a pipe, which spawns a shell and the command is then
> started in there.
> So, if your program quits, the spawned shell is still alive, only the
> pipe is dead.
Isn't it possible to open processes in such a way like terminals? If I
kill the terminal, everything open in it will die too.