【问题标题】:Is it possible to find the location of a file with the help of its PID?是否可以在 PID 的帮助下找到文件的位置?
【发布时间】:2020-06-15 09:29:37
【问题描述】:

我有一些 PID(进程 I'D),我必须找到这些 PID 所属文件的位置。我必须用python语言编写代码。有什么办法吗?

【问题讨论】:

    标签: python location exe pid


    【解决方案1】:

    你试过psutil吗? 安装psutil:

    pip install psutil
    

    psutil 有一个 exe 方法,它将返回运行进程的绝对路径:

    p = psutil.Process(pid)
    p.exe()
    

    输出会是这样的:

    '/usr/libexec/xartstorageremoted'
    

    【讨论】:

    猜你喜欢
    • 2012-11-01
    • 2023-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多