问题
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)
QtCore.QCoreApplication.instance().quit
return
button.clicked.connect(onExit)
logProc=os.fork()
if logProc>0:
proc()
回答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
is0
, 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.
来源:https://stackoverflow.com/questions/20259873/how-to-kill-a-child-process