Skip to content

fix(process): register interrupt handler before raising in windows test - #768

Merged
Mzack9999 merged 1 commit into
mainfrom
fix/windows-send-interrupt-flake
Aug 26, 2026
Merged

fix(process): register interrupt handler before raising in windows test#768
Mzack9999 merged 1 commit into
mainfrom
fix/windows-send-interrupt-flake

Conversation

@dogancanbakir

Copy link
Copy Markdown
Member

Fixes #767

TestSendInterrupt is flaky on windows-latest, and as written it is green only when SendInterrupt is too slow to matter.

The child branch raised the event with nothing watching SIGINT:

if os.Getenv("TEST_SEND_INTERRUPT_CHILD") == "1" {
    SendInterrupt()
    return
}

runtime.ctrlHandler maps CTRL_BREAK_EVENT to SIGINT but only consumes it when a handler is registered (if sigsend(s) { return 1 }). With no handler it returns 0 and Windows runs the default action — terminate with STATUS_CONTROL_C_EXIT (0xc000013a). Delivery is asynchronous, so it was a race between the handler thread and the child's return; the failing log shows the child emitting both PASS and exit status 0xc000013a.

This registers signal.Notify before raising and waits for the signal, matching what interrupt_unix_test.go already does. The race is gone (the handler consumes the event instead of the default action) and the test now asserts the thing it is named after. The parent-side re-exec with CREATE_NEW_PROCESS_GROUP is untouched — that is what keeps the break event away from sibling processes during go test ./....

GOOS=windows go vet ./process/ is clean; the behaviour itself needs the Windows runner to confirm, so watch this PR's Test Builds (windows-latest) job.

The child branch called SendInterrupt() with nothing watching SIGINT, so
runtime.ctrlHandler could not consume the CTRL_BREAK_EVENT and Windows
ran the default action instead, killing the child with
STATUS_CONTROL_C_EXIT (0xc000013a). Delivery is asynchronous, so the test
passed only when the child's return beat the handler thread -- i.e. when
the interrupt arrived too late to matter.

Register signal.Notify before raising and wait for the signal, matching
interrupt_unix_test.go. This removes the race and makes the test actually
assert that SendInterrupt delivers an interrupt.

Fixes #767
@dogancanbakir dogancanbakir self-assigned this Aug 26, 2026
@Mzack9999
Mzack9999 merged commit bae51aa into main Aug 26, 2026
7 checks passed
@Mzack9999
Mzack9999 deleted the fix/windows-send-interrupt-flake branch August 26, 2026 08:19
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.

TestSendInterrupt flaky on windows: child killed by STATUS_CONTROL_C_EXIT (0xc000013a)

2 participants