【发布时间】:2013-12-18 09:44:48
【问题描述】:
在 Linux Ubuntu 操作系统下,我运行 test.py 脚本,其中包含一个 GObject 循环,使用 subprocess by:
subprocess.call(["test.py"])
现在,这个test.py 将创建进程。有没有办法在 Python 中杀死这个进程?
注意:我不知道进程 ID。
很抱歉,如果我没有很清楚地解释我的问题,因为我是这种表单的新手,而且一般来说是 python 的新手。
【问题讨论】:
-
这行得通吗?
p = subprocess.call(["test.py"]);p.kill(). -
不,它给了我:
AttributeError: int object has no attribute kill -
这里有一个相关的(更复杂的)案例:Stop reading process output in Python without hang?
标签: python linux python-2.7 subprocess