daemon.py 文件源码

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

项目:amadash 作者: ipartola 项目源码 文件源码
def close_open_files():
    '''Closes all open files. Useful after a fork.'''

    maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1]
    if maxfd == resource.RLIM_INFINITY:
        maxfd = MAXFD

    for fd in reversed(range(maxfd)):
        try:
            os.close(fd)
        except OSError, e:
            if e.errno == errno.EBADF:
                pass # File not open
            else:
                raise Exception("Failed to close file descriptor %d: %s" % (fd, e))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号