Skip to content

Commit b873bb0

Browse files
committed
fix(windows): bypass daemon for tty commands (stress-test, demo, monitor, logs)
os.execv on Windows is emulated — spawned process inherits the JSON pipe as stdout, corrupting the daemon protocol. Fix: intercept these commands in dispatcher.py before the socket attempt and run them directly via subprocess.call with a real console. Remove the now-dead execv branch from cli.py.
1 parent 12259ea commit b873bb0

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

src/omnipkg/cli.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,18 +1949,6 @@ def main():
19491949
if args.tests:
19501950
safe_print(_(" Running tests: {}").format(", ".join(args.tests)))
19511951

1952-
if os.environ.get("OMNIPKG_DAEMON_WORKER") == "1":
1953-
# Running inside daemon worker - stdout is the JSON pipe.
1954-
# exec() replaces this worker process with the stress test,
1955-
# giving it a real stdin/stdout. The daemon sees the worker
1956-
# exit and handles it the same as any other worker death.
1957-
env = os.environ.copy()
1958-
env.pop("OMNIPKG_DAEMON_WORKER", None)
1959-
os.environ.update(env)
1960-
if sys.platform == "win32":
1961-
os.execv(cmd[0], cmd)
1962-
else:
1963-
os.execv(cmd[0], cmd)
19641952
return subprocess.call(cmd)
19651953

19661954
elif args.command == "install":

src/omnipkg/dispatcher.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,19 @@ def main():
239239
)
240240
is_interactive_command = is_info_command or is_config_command or is_logs_follow
241241

242+
# Commands that need a real TTY (streaming output, interactive, long-running).
243+
# Bypass the daemon entirely and run directly as a subprocess.
244+
_DIRECT_COMMANDS = {"stress-test", "demo", "monitor", "logs"}
245+
is_direct_command = bool(argv_commands) and argv_commands[0] in _DIRECT_COMMANDS
246+
247+
if is_direct_command:
248+
import subprocess
249+
exec_args = [str(target_python), "-m", "omnipkg.cli"] + sys.argv[1:]
250+
if debug_mode:
251+
print(f'[DEBUG-DISPATCH] Direct (no-daemon) command: {argv_commands[0]}', file=sys.stderr)
252+
print(f'[DEBUG-DISPATCH] Executing: {" ".join(exec_args)}', file=sys.stderr)
253+
sys.exit(subprocess.call(exec_args))
254+
242255
if not is_swap_command and not is_daemon_lifecycle and not is_interactive_command:
243256
try:
244257
import socket

0 commit comments

Comments
 (0)