Hide transient command windows
This commit is contained in:
@@ -487,6 +487,7 @@ def _find_listening_pids(port: int) -> set[int]:
|
||||
text=True,
|
||||
errors="replace",
|
||||
shell=False,
|
||||
creationflags=_hidden_process_creation_flags(),
|
||||
)
|
||||
if result.returncode != 0:
|
||||
message = result.stderr.strip() or f"netstat 退出码 {result.returncode}"
|
||||
@@ -502,6 +503,7 @@ def _terminate_process_tree(pid: int) -> None:
|
||||
text=True,
|
||||
errors="replace",
|
||||
shell=False,
|
||||
creationflags=_hidden_process_creation_flags(),
|
||||
)
|
||||
if result.returncode != 0:
|
||||
message = result.stdout.strip() or f"taskkill 退出码 {result.returncode}"
|
||||
@@ -744,6 +746,12 @@ def _background_creation_flags() -> int:
|
||||
return subprocess.DETACHED_PROCESS | subprocess.CREATE_NEW_PROCESS_GROUP
|
||||
|
||||
|
||||
def _hidden_process_creation_flags() -> int:
|
||||
if os.name != "nt":
|
||||
return 0
|
||||
return getattr(subprocess, "CREATE_NO_WINDOW", 0)
|
||||
|
||||
|
||||
def _backend_console_creation_flags() -> int:
|
||||
if os.name != "nt":
|
||||
return 0
|
||||
@@ -904,6 +912,7 @@ def _run_process(
|
||||
stderr=subprocess.STDOUT,
|
||||
env=process_environment,
|
||||
shell=False,
|
||||
creationflags=_hidden_process_creation_flags(),
|
||||
)
|
||||
assert process.stdout is not None
|
||||
for raw_line in process.stdout:
|
||||
|
||||
Reference in New Issue
Block a user