config.py 文件源码

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

项目:ave 作者: sonyxperiadev 项目源码 文件源码
def check_fds(pretty, dump, ref):
    # check that 0-2 are the stdio file descriptors. i.e. that they are
    # connected to pseudo terminals.
    for i in range(3):
         if not dump[i].startswith('/dev/pts'):
             print('FAIL %s: wrong stdio file at %d: %s' % (pretty, i, dump[i]))
             os._exit(2)

    # any file descriptors in the range [3..max(all fds)] must be files that
    # were opened by this process. for this test we expect all of them to point
    # to the same file (the current .py file). otherwise they are not intact.
    if max(dump.keys()) <= 2:
        os._exit(0) # all OK
    for i in range(3, max(ref.keys())): # check that all ref keys are intact
        if not dump[i] == ref[i]:
            print('FAIL %s: clobbered fd at %d: %s' % (pretty, i, dump[i]))
            os._exit(5)

# check if ave.config.load_etc() clobbers file descriptors. this is a bug in
# winbindd which is used by PAM to implement a backend for Python's pwd module.
# we *have* to use the pwd module, so the global side effect (clobbering a file
# descriptor) must be hidden from the caller.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号