Den Thu, 07 Jun 2007 07:00:53 +0000 skrev reed: > On Jun 5, 7:58 am, Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote: >> Hi, When I do a small program like >> >> from subprocess import Popen >> popen = Popen(["ping", "google.com"]) from time import sleep >> sleep(100) >> >> 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 >> is? >> 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') > pidfile.close()
> 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? -- http://mail.python.org/mailman/listinfo/python-list