Skip to content

fix(service): start the detached service without a console window on Windows - #267

Merged
Zongwei9888 merged 1 commit into
HKUDS:mainfrom
raymondginger2018-sudo:pr/service-no-console
Oct 21, 2026
Merged

Zongwei9888 merged 1 commit into
HKUDS:mainfrom
raymondginger2018-sudo:pr/service-no-console

Conversation

@raymondginger2018-sudo

Copy link
Copy Markdown
Contributor

DETACHED_PROCESS makes Windows allocate a brand-new console for the service, which default terminal hosts surface as a visible window on every service start. CREATE_NO_WINDOW still runs without any window and still outlives the launcher (the console is private to the child, never inherited). CREATE_NEW_PROCESS_GROUP is kept.

The detached-parametrization replica in tests/app_server/test_service.py mirrors the flag change.

Verification

tests/app_server/test_service.py on Windows 11: 30 passed.

Checks

  • Dedup: main still uses DETACHED_PROCESS at cli/service_cli.py:174.
  • Dependency closure: stdlib only.
  • Scope: 2 files, +9/-2.

…Windows

DETACHED_PROCESS makes Windows allocate a brand-new console for the child.
With Windows Terminal (ConPTY) as the default terminal handler that console
surfaces as a real, visible WindowsTerminal window on every `service start`,
which floods the desktop when the CLI is driven from a harness that starts
and stops the service repeatedly.

CREATE_NO_WINDOW keeps the process windowless -- the console is private to
the child and never inherited -- while still outliving the launcher, so the
detached contract is unchanged. CREATE_NO_WINDOW is ignored when it is
combined with DETACHED_PROCESS, hence the replacement rather than an
addition; CREATE_NEW_PROCESS_GROUP is kept.

The replica in tests/app_server/test_service.py mirrors the flag, so the
detached parametrization stops spawning a console window as well.
@Zongwei9888
Zongwei9888 merged commit 249efc2 into HKUDS:main Oct 21, 2026
12 checks passed
@Zongwei9888

Copy link
Copy Markdown
Collaborator

Merged into main on 2026-10-21 as 249efc2 ("Merge PR #267: start the Windows service without a console window"). Thank you, the flag change is right and Windows CI passed with it.

One follow-up on main in e40ac1d rewords the comment in cli/service_cli.py. A DETACHED_PROCESS child has no console at all; the visible windows came from the console programs the service starts (the real interpreter behind a venv's python.exe, shells, MCP stdio servers), each of which got a console of its own, and closing one could stop the service. CREATE_NO_WINDOW gives the service a hidden console those programs share, so the fix covers more than the original comment said.

It's in the README news for 2026-10-21.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants