Skip to content

fix: detach sc.exe from parent shell on Windows#3

Merged
rferreira merged 1 commit intomainfrom
change/windows-server-detach
Apr 29, 2026
Merged

fix: detach sc.exe from parent shell on Windows#3
rferreira merged 1 commit intomainfrom
change/windows-server-detach

Conversation

@rferreira
Copy link
Copy Markdown
Contributor

Problem

Windows CI was failing with "scanii-cli did not become ready within 30 seconds." (scanii-ruby#1 — Windows job).

Diagnosis: MSYS2 bash does not properly detach native Windows processes when backgrounded with bare &. When the bash shell exits at the end of the "Start scanii-cli server" step, sc.exe inherits closed stdio and dies on its first write attempt. The subsequent curl readiness loop hits a closed port for the full 30 seconds. Diagnostic confirmation: the server banner prints once, then no further output appears during the curl loop — if the process were alive, request log lines would appear.

Fix

Three load-bearing changes in the "Start scanii-cli server" step:

  1. > "$LOG" 2>&1 — redirect stdio to $RUNNER_TEMP/scanii-cli.log. This is the actual fix: sc.exe now has a live file descriptor for writes, so it survives the parent shell exiting.
  2. nohup — protects against SIGHUP on Linux/macOS; harmless on Windows.
  3. disown — removes the job from bash's job table so the shell exits without waiting on it.

Also surfaces the log file on the timeout path so future failures are easier to diagnose.

Contract unchanged

Inputs, outputs, and branding are identical. This is a pure bug fix.

MSYS2 bash does not properly detach native Windows processes with bare
`&`; when the shell exits the step, sc.exe inherits closed stdio and
dies on its first write. Add nohup, redirect stdio to a log file in
RUNNER_TEMP, and disown the job so the shell exits cleanly without
taking the server with it. Also surface the log on the timeout path
to ease future diagnostics.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rferreira rferreira merged commit cb6bcb2 into main Apr 29, 2026
3 checks passed
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