subprocess leaves child living
Thomas Dybdahl Ahle
lobais at gmail.com
Thu Jun 7 15:48:51 CEST 2007
Den Thu, 07 Jun 2007 07:00:53 +0000 skrev reed:
> On Jun 5, 7:58 am, Thomas Dybdahl Ahle <lob... at gmail.com> wrote:
>> Hi, When I do a small program like
>> from subprocess import Popen
>> popen = Popen(["ping", "google.com"]) from time import sleep
>> start it and kill it, the ping process lives on. Is there a way to
>> ensure that the ping process is always killed when the python process
>> I can't use atexit, as ping then isn't killed when python is killed "in
>> the hard way"
> pid = popen.pid
> pidfile = open('/usr/local/var/somefile.pid', 'w') pidfile.write('pid')
> then you can check if it is still running when your ?program? restarts
> and can kill it.
If it restarts yeah.
> maybe not the perfect answer, but it answers an imperfect question.
Any details you need?
More information about the Python-list