posix.py 文件源码

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

项目:ptterm 作者: jonathanslenders 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号