mirror of
https://github.com/GuDaStudio/codexmcp.git
synced 2026-02-13 02:51:48 +08:00
v0.4.1:修复Windows下无限挂起bug
This commit is contained in:
@@ -33,12 +33,18 @@ def run_shell_command(cmd: list[str]) -> Generator[str, None, None]:
|
|||||||
Yields:
|
Yields:
|
||||||
Output lines from the command
|
Output lines from the command
|
||||||
"""
|
"""
|
||||||
# On Windows, wrap command with cmd.exe to execute .cmd batch files
|
# On Windows, codex is exposed via a *.cmd shim. Use cmd.exe with /s so
|
||||||
popen_cmd = ["cmd", "/c", *cmd] if os.name == "nt" else cmd
|
# user prompts containing quotes/newlines aren't reinterpreted as shell syntax.
|
||||||
|
if os.name == "nt":
|
||||||
|
quoted_cmd = subprocess.list2cmdline(cmd)
|
||||||
|
popen_cmd = ["cmd", "/d", "/s", "/c", quoted_cmd]
|
||||||
|
else:
|
||||||
|
popen_cmd = cmd
|
||||||
|
|
||||||
process = subprocess.Popen(
|
process = subprocess.Popen(
|
||||||
popen_cmd,
|
popen_cmd,
|
||||||
shell=False, # Safer: no shell injection
|
shell=False, # Safer: no shell injection
|
||||||
|
stdin=subprocess.DEVNULL, # Prevent process from waiting for input
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
universal_newlines=True,
|
universal_newlines=True,
|
||||||
|
|||||||
Reference in New Issue
Block a user