pstree.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:LinuxBashShellScriptForOps 作者: DingGuodong 项目源码 文件源码
def main():
    # construct a dict where 'values' are all the processes
    # having 'key' as their parent
    tree = collections.defaultdict(list)
    for p in psutil.process_iter():
        try:
            tree[p.ppid()].append(p.pid)
        except (psutil.NoSuchProcess, psutil.ZombieProcess):
            pass
    # on systems supporting PID 0, PID 0's parent is usually 0
    if 0 in tree and 0 in tree[0]:
        tree[0].remove(0)
    print_tree(min(tree), tree)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号