如何杀死一个孩子的过程 [英] How to kill a child process
本文介绍了如何杀死一个孩子的过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我发现了几种杀死子进程的方法.我想使用os.kill(pid).但这不起作用,我想应该可以.
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()
推荐答案
您应该将 signal.SIGKILL
(9), signal.SIGTERM
(15)之类的信号传递给终止进程.
You should pass signals like signal.SIGKILL
(9), signal.SIGTERM
(15) to kill the process.
import signal
...
os.kill(logProc, signal.SIGKILL)
根据Linux kill(2)
:
如果
sig
为0
,则未发送信号,但仍执行错误检查;可以用来检查是否存在进程ID或进程组ID.
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.
这篇关于如何杀死一个孩子的过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文