posix.py 文件源码

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

项目:ptterm 作者: jonathanslenders 项目源码 文件源码
def from_command(cls, command, before_exec_func=None):
        """
        Create Process from command,
        e.g. command=['python', '-c', 'print("test")']

        :param before_exec_func: Function that is called before `exec` in the
            process fork.
        """
        assert isinstance(command, list)
        assert before_exec_func is None or callable(before_exec_func)

        def execv():
            if before_exec_func:
                before_exec_func()

            for p in os.environ['PATH'].split(':'):
                path = os.path.join(p, command[0])
                if os.path.exists(path) and os.access(path, os.X_OK):
                    os.execv(path, command)

        return cls(execv)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号