utils.py 文件源码

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

项目:treadmill 作者: Morgan-Stanley 项目源码 文件源码
def sane_execvp(filename, args, close_fds=True, restore_signals=True):
    """Execute a new program with sanitized environment.
    """
    def _restore_signals():
        """Reset the default behavior to all signals.
        """
        for i in _SIGNALS:
            signal.signal(i, signal.SIG_DFL)

    def _close_fds():
        """Close all file descriptors except 0, 1, 2.
        """
        os.closerange(3, subprocess.MAXFD)

    if close_fds:
        _close_fds()
    if restore_signals:
        _restore_signals()
    os.execvp(filename, args)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号