[PATCH 1 of 2] win32: specify _CREATE_NO_WINDOW on spawndetached()

Adrian Buehlmann adrian at cadifra.com
Mon Jun 25 12:46:17 CDT 2012


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1340644289 -7200
# Node ID 3f2656c03b08bfa04519534db67ac6a0ae69d77d
# Parent  9ab2624815a9facb1e581fd07fa81fe852b769ec
win32: specify _CREATE_NO_WINDOW on spawndetached()

Before this change, a console window briefly popped up on "hg serve -d" and
disappeared again, stealing the focus window (which was very annyoing when
running tests).

Specifying _CREATE_NO_WINDOW instead of _DETACHED_PROCESS fixes this (as tested
on Windows 7 x64).

diff --git a/mercurial/win32.py b/mercurial/win32.py
--- a/mercurial/win32.py
+++ b/mercurial/win32.py
@@ -97,7 +97,7 @@
                 ('dwProcessId', _DWORD),
                 ('dwThreadId', _DWORD)]
 
-_DETACHED_PROCESS = 0x00000008
+_CREATE_NO_WINDOW = 0x08000000
 _STARTF_USESHOWWINDOW = 0x00000001
 _SW_HIDE = 0
 
@@ -337,7 +337,7 @@
     args = comspec + " /c " + args
 
     res = _kernel32.CreateProcessA(
-        None, args, None, None, False, _DETACHED_PROCESS,
+        None, args, None, None, False, _CREATE_NO_WINDOW,
         env, os.getcwd(), ctypes.byref(si), ctypes.byref(pi))
     if not res:
         raise ctypes.WinError


More information about the Mercurial-devel mailing list