【发布时间】:2013-07-28 07:51:42
【问题描述】:
我需要一些关于子进程终止后的信息。
如utime和VMPeak在/proc这样:
proc.wait()
with open('/proc/%d/stat' % proc.pid, "r") as f:
stat = str(f.read()).strip().split()
# 14th column is utime, 15th column is stime (man 5 proc)
cpu_time = int(stat[14]) + int(stat[15])
return cpu_time
但是 Python Popen.wait() 发布了PID,所以我会得到:
No such file or directory
我能否在终止后,或等待终止而不释放PID? (我的意思是等待终止没有调用wait(),这将释放所有资源。)
如果您能帮助我,我将不胜感激。谢谢!
【问题讨论】:
-
这不是python的问题,而是Linux编程的问题。
标签: python linux process popen pid