def get_name_for_fd(fd):
"""
Return the process name for a given process ID.
"""
try:
pgrp = os.tcgetpgrp(fd)
except OSError:
# See: https://github.com/jonathanslenders/pymux/issues/46
return
try:
with open('/proc/%s/cmdline' % pgrp, 'rb') as f:
return f.read().decode('utf-8', 'ignore').partition('\0')[0]
except IOError:
pass
评论列表
文章目录