extutil: make background run truly background

Summary:
`DETACHED_PROCESS` simply means that child process won't inherit
current process' console (it does get one allocated by the OS though). `CREATE_NO_WINDOW` means that child
process does not get an allocated console altogether.

For details: https://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx

Reviewed By: quark-zju

Differential Revision: D7969621

fbshipit-source-id: 58d5e69808fb1064bcc1101c971f52088a7fd2de
This commit is contained in:
Kostia Balytskyi 2018-05-11 09:53:55 -07:00 committed by Facebook Github Bot
parent a2e7d1cfe3
commit b955fc974e

View File

@ -22,11 +22,8 @@ from mercurial import (
)
if pycompat.iswindows:
# no fork on Windows, but we can create a detached process
# https://msdn.microsoft.com/en-us/library/windows/desktop/ms684863.aspx
# No stdlib constant exists for this value
DETACHED_PROCESS = 0x00000008
_creationflags = DETACHED_PROCESS | subprocess.CREATE_NEW_PROCESS_GROUP
CREATE_NO_WINDOW = 0x08000000
_creationflags = CREATE_NO_WINDOW | subprocess.CREATE_NEW_PROCESS_GROUP
def runbgcommand(script, env, shell=False, stdout=None, stderr=None):
'''Spawn a command without waiting for it to finish.'''