diff options
author | Peter Astrand <astrand@lysator.liu.se> | 2004-11-07 14:30:34 (GMT) |
---|---|---|
committer | Peter Astrand <astrand@lysator.liu.se> | 2004-11-07 14:30:34 (GMT) |
commit | c1d6536d60c39475895fb8691f81510393b9737b (patch) | |
tree | ee298865f6cc3e0cdc8ea39bdc6c613475f468e5 /Lib/subprocess.py | |
parent | 80961f3ca90ab48470fad8bb2310f19896ec9b7b (diff) | |
download | cpython-c1d6536d60c39475895fb8691f81510393b9737b.zip cpython-c1d6536d60c39475895fb8691f81510393b9737b.tar.gz cpython-c1d6536d60c39475895fb8691f81510393b9737b.tar.bz2 |
When using shell=True on Windows, don't display a shell window by default. Fixes #1057061.
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r-- | Lib/subprocess.py | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py index 76ea25f..db19d1f 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -372,11 +372,11 @@ if mswindows: STD_OUTPUT_HANDLE, STD_ERROR_HANDLE from win32api import GetCurrentProcess, DuplicateHandle, \ GetModuleFileName, GetVersion - from win32con import DUPLICATE_SAME_ACCESS + from win32con import DUPLICATE_SAME_ACCESS, SW_HIDE from win32pipe import CreatePipe from win32process import CreateProcess, STARTUPINFO, \ GetExitCodeProcess, STARTF_USESTDHANDLES, \ - CREATE_NEW_CONSOLE + STARTF_USESHOWWINDOW, CREATE_NEW_CONSOLE from win32event import WaitForSingleObject, INFINITE, WAIT_OBJECT_0 else: from _subprocess import * @@ -673,7 +673,19 @@ class Popen(object): if not isinstance(args, types.StringTypes): args = list2cmdline(args) + # Process startup details + default_startupinfo = STARTUPINFO() + if startupinfo == None: + startupinfo = default_startupinfo + if not None in (p2cread, c2pwrite, errwrite): + startupinfo.dwFlags |= STARTF_USESTDHANDLES + startupinfo.hStdInput = p2cread + startupinfo.hStdOutput = c2pwrite + startupinfo.hStdError = errwrite + if shell: + default_startupinfo.dwFlags |= STARTF_USESHOWWINDOW + default_startupinfo.wShowWindow = SW_HIDE comspec = os.environ.get("COMSPEC", "cmd.exe") args = comspec + " /c " + args if (GetVersion() >= 0x80000000L or @@ -692,15 +704,6 @@ class Popen(object): # kill children. creationflags |= CREATE_NEW_CONSOLE - # Process startup details - if startupinfo == None: - startupinfo = STARTUPINFO() - if not None in (p2cread, c2pwrite, errwrite): - startupinfo.dwFlags |= STARTF_USESTDHANDLES - startupinfo.hStdInput = p2cread - startupinfo.hStdOutput = c2pwrite - startupinfo.hStdError = errwrite - # Start the process try: hp, ht, pid, tid = CreateProcess(executable, args, |