Skip to content Skip to sidebar Skip to footer

How To Kill A Child Process

I've found several methods to kill a child process. I would like to use the os.kill(pid). But it doesn't work, I guess it should though. def onExit(): os.kill(logProc, 0) Q

Solution 1:

You should pass signals like signal.SIGKILL (9), signal.SIGTERM (15) to kill the process.

import signal

...

os.kill(logProc, signal.SIGKILL)

According to Linux kill(2):

If sig is 0, then no signal is sent, but error checking is still performed; this can be used to check for the existence of a process ID orprocess group ID.

Post a Comment for "How To Kill A Child Process"