[3.7] bpo-33929: multiprocessing: fix handle leak on race condition (GH-7921) by miss-islington · Pull Request #7960 · python/cpython
def _close_handles(*handles): for handle in handles: _winapi.CloseHandle(handle)
# # We define a Popen class similar to the one from subprocess, but # whose constructor takes a process object as its argument.
# read end of pipe will be "stolen" by the child process # read end of pipe will be duplicated by the child process # -- see spawn_main() in spawn.py. # # bpo-33929: Previously, the read end of pipe was "stolen" by the child # process, but it leaked a handle if the child process had been # terminated before it could steal the handle from the parent process. rhandle, whandle = _winapi.CreatePipe(None, 0) wfd = msvcrt.open_osfhandle(whandle, 0) cmd = spawn.get_command_line(parent_pid=os.getpid(),
# send information to child set_spawning_popen(self)