【发布时间】:2012-08-15 09:22:06
【问题描述】:
有没有办法确定进程/PID 是否处于暂停状态?
当前使用Popen("kill -STOP "+str(pid),shell=True) 暂停进程。
确定给定 pid 是否处于暂停状态的推荐方法是什么?
【问题讨论】:
-
希望这篇文章能帮到你stackoverflow.com/questions/6021771/…
标签: python subprocess pid
有没有办法确定进程/PID 是否处于暂停状态?
当前使用Popen("kill -STOP "+str(pid),shell=True) 暂停进程。
确定给定 pid 是否处于暂停状态的推荐方法是什么?
【问题讨论】:
标签: python subprocess pid
您可以阅读/proc/:pid/stat 或/proc/:pid/status,例如:
Name: python
State: T (stopped)
【讨论】:
def is_paused(pid): return open("/proc/{0}/stat".format(pid)).read().split()[2] == "T"
IOError: [Errno 2] No such file or directory: '/proc/2374/stat'