Patchwork win32: close the handles associated with a spawned child process

login
register
mail settings
Submitter Matt Harbison
Date Dec. 12, 2018, 4:08 a.m.
Message ID <ec40f2ca8ac974ef657d.1544587711@Envy>
Download mbox | patch
Permalink /patch/37116/
State Accepted
Headers show

Comments

Matt Harbison - Dec. 12, 2018, 4:08 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1544583474 18000
#      Tue Dec 11 21:57:54 2018 -0500
# Node ID ec40f2ca8ac974ef657d4d52ac78019e75444911
# Parent  76d8b20139a3b8b5835c7262216b97275845b582
win32: close the handles associated with a spawned child process

Probably not a big deal because at this point, the call is only used when
spawning a daemonized server.  In that case, the parent process goes away first,
so it won't prevent the child from being cleaned up.
Yuya Nishihara - Dec. 12, 2018, 11:56 a.m.
On Tue, 11 Dec 2018 23:08:31 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1544583474 18000
> #      Tue Dec 11 21:57:54 2018 -0500
> # Node ID ec40f2ca8ac974ef657d4d52ac78019e75444911
> # Parent  76d8b20139a3b8b5835c7262216b97275845b582
> win32: close the handles associated with a spawned child process

Queued, thanks.

Patch

diff --git a/mercurial/win32.py b/mercurial/win32.py
--- a/mercurial/win32.py
+++ b/mercurial/win32.py
@@ -588,6 +588,9 @@  def spawndetached(args):
     if not res:
         raise ctypes.WinError()
 
+    _kernel32.CloseHandle(pi.hProcess)
+    _kernel32.CloseHandle(pi.hThread)
+
     return pi.dwProcessId
 
 def unlink(f):