Skip to content

fix: guard SIGTERM grace period in shutdown on Windows (#14302) - #14316

Merged
robinbb merged 1 commit into
ocaml:mainfrom
robinbb:robinbb-issue-14302-windows-signals
Apr 24, 2026
Merged

fix: guard SIGTERM grace period in shutdown on Windows (#14302)#14316
robinbb merged 1 commit into
ocaml:mainfrom
robinbb:robinbb-issue-14302-windows-signals

Conversation

@robinbb

@robinbb robinbb commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #14302.

PR #14170 added a SIGTERM-before-SIGKILL grace period to
kill_and_wait_for_all_processes. The new polling loop calls
Process_watcher.wait_unix unconditionally, which on Windows routes through
Proc.wait and raises Code_error "wait4 not available on windows", crashing
dune on Ctrl+C.

Fix

Since SIGTERM is not meaningful on Windows anyway — as PR #14170 itself noted
("On Windows, where SIGTERM is not meaningful, behavior is unchanged") — skip
the grace-period pre-phase on Windows and send SIGKILL directly. The existing
main drain loop already handles the Windows case correctly: job exits are
pushed to jobs_completed by the run_win32 polling thread and decrement
pending_jobs when popped by Event.Queue.next (see
src/dune_scheduler/event.ml:222 and :187-191).

Changelog

Added doc/changes/fixed/14302.md.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a Windows-only crash in Dune’s shutdown path introduced by the SIGTERM-grace-period change in #14170, by avoiding Unix-only process waiting APIs on Windows.

Changes:

  • Skip the SIGTERM grace-period pre-phase on Windows and send SIGKILL directly in kill_and_wait_for_all_processes.
  • Add a changelog entry documenting the Windows crash fix (#14302).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/dune_scheduler/scheduler.ml Guards the SIGTERM/grace-period polling loop so Windows doesn’t call Process_watcher.wait_unix; uses direct SIGKILL instead.
doc/changes/fixed/14302.md Documents the Windows shutdown crash fix and rationale.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@robinbb
robinbb marked this pull request as ready for review April 24, 2026 00:45
@robinbb
robinbb requested a review from Alizter April 24, 2026 01:35

@Alizter Alizter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this requires a changelog since this is a regression introduced before we release 3.23 and is blocking the release.

I've tested the patch on Windows before and after and it appears to work correctly.

Fixes ocaml#14302.

PR ocaml#14170 added a SIGTERM-before-SIGKILL grace period to
[kill_and_wait_for_all_processes]. The new polling loop calls
[Process_watcher.wait_unix] unconditionally, which on Windows routes
through [Proc.wait] and raises:

    Code_error "wait4 not available on windows"

Since SIGTERM is not meaningful on Windows anyway (as PR ocaml#14170 itself
noted), skip the grace-period pre-phase there and send SIGKILL directly.
The main drain loop already handles the Windows case correctly: job
exits are pushed to [jobs_completed] by the [run_win32] polling thread
and decrement [pending_jobs] when popped by [Event.Queue.next].

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
@robinbb
robinbb force-pushed the robinbb-issue-14302-windows-signals branch from ec8aafd to 9944251 Compare April 24, 2026 17:14
@robinbb

robinbb commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator Author

Dropped the changelog entry (commit 9944251). Thanks for the Windows validation.

@Alizter Alizter mentioned this pull request Apr 24, 2026
19 tasks
@robinbb
robinbb merged commit a6ec61a into ocaml:main Apr 24, 2026
31 checks passed
@robinbb
robinbb deleted the robinbb-issue-14302-windows-signals branch April 24, 2026 19:12
@Alizter Alizter added this to the 3.23.0 milestone Jul 8, 2026
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.

Ctrl + C to terminate Dune on Windows no longer works

3 participants