]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-33929: Fix regression in spawn_main() (#7962)
authorVictor Stinner <vstinner@redhat.com>
Wed, 27 Jun 2018 13:18:39 +0000 (15:18 +0200)
committerGitHub <noreply@github.com>
Wed, 27 Jun 2018 13:18:39 +0000 (15:18 +0200)
OpenProcess() creates a new handle that must be closed later.

Lib/multiprocessing/spawn.py

index 2de4cb7f6378be5bf0936ceacbcf69933d1ef60e..73aa69471f29c3a8f6e513d7ada6fa6afb0fcf6a 100644 (file)
@@ -103,8 +103,12 @@ def spawn_main(pipe_handle, parent_pid=None, tracker_fd=None):
                 _winapi.PROCESS_DUP_HANDLE, False, parent_pid)
         else:
             source_process = None
-        new_handle = reduction.duplicate(pipe_handle,
-                                         source_process=source_process)
+        try:
+            new_handle = reduction.duplicate(pipe_handle,
+                                             source_process=source_process)
+        finally:
+            if source_process is not None:
+                _winapi.CloseHandle(source_process)
         fd = msvcrt.open_osfhandle(new_handle, os.O_RDONLY)
     else:
         from . import semaphore_tracker