how to kill a process

Richard Rossel henhiskan at
Tue Jun 12 18:01:01 CEST 2007

Hi Fellows,
I have a problem with process termination. I have a python code that
apache runs through a django interface.
The code is very simple, first, it creates a process with the
subprocess.Popen call, and afterwards, (using a web request) the
python code uses the PID of the previously created process(stored in a
db) and kills it with an os.kill call using the SIGKILL signal.

The creation of the process is ok, apache calls the python code, this
code creates the process and exits leaving the process up and
running :)
But when the python code is called to kill the created process, the
process is left in a zombie state.

The kill code that I'm using is:
os.kill(pid, signal.SIGKILL)

and I also tried:
 kill_proc = Popen("kill -9 " + pid, shell=true)
but with no success.

I suppose that the reason maybe that the python code exits before the
kill call has finished,
so I tried with a while loop until kill_proc.poll() != None, but
without success too :(

do you know what is what I'm doing wrong?

thanks very much.-

More information about the Python-list mailing list