fix: wait for the Python console runtime on Windows

This commit is contained in:
Tianyi Cui
2026-09-06 19:53:23 +08:00
parent cd5e872bed
commit 6f21b112da
10 changed files with 138 additions and 6 deletions
@@ -24,6 +24,7 @@ from __future__ import annotations
import os
import platform
import shutil
import subprocess
import sys
from pathlib import Path
@@ -156,7 +157,7 @@ def _node_launch_args() -> tuple[str, str]:
def main() -> None:
"""Execute the bundled dsh CLI with an explicitly selected Harness home."""
"""Launch the CLI with explicit DSH_HOME; wait on Windows, replace the process on POSIX."""
if not os.environ.get("DSH_HOME", "").strip():
print(
"dsh: the Python runtime command requires an explicit DSH_HOME; "
@@ -165,6 +166,9 @@ def main() -> None:
)
raise SystemExit(2)
argv = (*resolve_bundled_launch_args(), *sys.argv[1:])
if sys.platform == "win32":
# Windows CRT exec does not replace the process; wait and preserve the runtime status.
raise SystemExit(subprocess.run(argv, env=os.environ).returncode)
os.execvpe(argv[0], argv, os.environ)