📜  python 获取 pid 的用户 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:08.836000             🧑  作者: Mango

代码示例1
def owner(pid):
    '''Return username of UID of process pid'''
    for ln in open('/proc/%d/status' % pid):
        if ln.startswith('Uid:'):
            uid = int(ln.split()[UID])
            return pwd.getpwuid(uid).pw_name