fix: detach sc.exe from parent shell on Windows#3
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.exeinherits 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:
> "$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.nohup— protects against SIGHUP on Linux/macOS; harmless on Windows.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.