在Linux中,您可以使用procfs:
>>> os.readlink('/proc/%d/exe' % os.getppid())
'/bin/bash'
Run Code Online (Sandbox Code Playgroud)
os.getppid()返回父进程的PID.这是便携式的.但是获取进程名称不能以便携方式完成.您可以解析ps所有unices上可用的输出,例如使用psutil.
| 归档时间: |
|
| 查看次数: |
1108 次 |
| 最近记录: |