Skip to content

fix(shim): create niu.exe with CREATE_NO_WINDOW when stdio is piped (niubash#379) - #668

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/shim-create-no-window
Oct 16, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/shim-create-no-window

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

fix(shim): no more black console flash per invocation (niubash#379)

What

bash.exe (the src/bin/bash.rs shim) spawns niu.exe with inherited
stdio and zero creation flags. When a GUI parent with no console of its
own (Claude Code) launches the shim with piped stdio, Windows allocates
a visible console for the child — one black flash per command.

Fix

Gate on all-three-stdio-redirected (pure std, no new dependency):
none of stdin/stdout/stderr is a console ⇒ CREATE_NO_WINDOW
(0x08000000) on the child. Interactive console sessions always keep
at least stdin on a console and take the unchanged path — a console-less
child can still do plain I/O on inherited handles, but console APIs
(ReadConsole/SetConsoleMode) fail in it, so interactive niu must
keep inheriting the real console. Non-Windows is a no-op.

Verification

  • cargo build --bin bash clean, cargo test --bin bash 4/4, cargo fmt --check clean; shim still forwards (bash -c 'echo shim-alive' ok).
  • Full engine gate not applicable (shim-only change, no executor code);
    CI runs the standard checks.
  • Honestly unverifiable here: no Windows GUI parent on this box. Needs a
    Windows confirmation (flash gone for piped -c, interactive console
    unchanged) before release. The fix reaches the reporter via the next
    niubash installer (rubash bump + release build).

…niubash#379)

A GUI parent with no console of its own (Claude Code spawning the
bash.exe shim with piped stdio) makes Windows allocate a visible
console for the niu.exe child: one black flash per invocation. The shim
forwarded the command line and inherited handles without ever setting
creation flags.

When none of our own stdio is a console there is no console to
inherit, so the child is created CREATE_NO_WINDOW (0x08000000). An
interactive console session always keeps at least stdin on a console
and takes the unchanged path (a console-less child can still use
inherited console handles for plain I/O, but console APIs fail in it,
so interactive niu must keep the real console); non-Windows is a no-op.

Unverifiable on this box (no Windows GUI parent here): needs a Windows
reporter/CI confirmation that the flash is gone and interactive use is
unchanged.
@caomengxuan666
caomengxuan666 merged commit eaa6138 into master Oct 16, 2026
8 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/shim-create-no-window branch October 16, 2026 13:08
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.

1 participant