gipc.py 文件源码

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

项目:gipc 作者: jgehrcke 项目源码 文件源码
def _winapi_childhandle_after_createprocess_parent(self):
        """Called on Windows in the parent process after the CreateProcess()
        system call. This method is intended to revert the actions performed
        within `_winapi_childhandle_prepare_transfer()`. In particular, this
        method is intended to prepare a subsequent call to the handle's
        `close()` method.
        """
        if WINAPI_HANDLE_TRANSFER_STEAL:
            del self._parent_winapihandle
            del self._parent_pid
            # Setting `_fd` to None prevents the subsequent `close()` method
            # invocation (triggered in `start_process()` after child creation)
            # from actually calling `os.close()` on the file descriptor. This
            # must be prevented because at this point the handle either already
            # is or will be "stolen" by the child via a direct WinAPI call using
            # the DUPLICATE_CLOSE_SOURCE option (and therefore become
            # auto-closed, here, in the parent). The relative timing is not
            # predictable. If the child process steals first, os.close() here
            # would result in `OSError: [Errno 9] Bad file descriptor`. If
            # os.close() is called on the handle in the parent before the child
            # can steal the handle, a `OSError: [WinError 6] The handle is
            # invalid` will be thrown in the child upon the stealing attempt.
            self._fd = None
            return
        # Get C file descriptor from Windows file handle.
        self._fd = msvcrt.open_osfhandle(
            self._inheritable_winapihandle, self._fd_flag)
        del self._inheritable_winapihandle
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号