Skip to content

Backport #12538: Handle Ctrl+C on Windows terminals - #12550

Merged
gnodet merged 1 commit into
maven-4.0.xfrom
backport-12538-to-maven-4.0.x
Jul 27, 2026
Merged

Backport #12538: Handle Ctrl+C on Windows terminals#12550
gnodet merged 1 commit into
maven-4.0.xfrom
backport-12538-to-maven-4.0.x

Conversation

@gnodet

@gnodet gnodet commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Backport of #12538 to maven-4.0.x.

Cherry-pick of a3e576b with a minor conflict resolution to preserve the ProjectBuildLogAppender block present on this branch.


Original PR: #12538
Original issue: #12536

On Windows, JLine puts the terminal into raw mode and consumes Ctrl+C as console input before the JVM sees it. This registers a Terminal.Signal.INT handler that calls System.exit(130) (128 + SIGINT) to restore proper Ctrl+C behavior, guarded by OSUtils.IS_WINDOWS and !embedded().

On Windows, JLine handles Ctrl+C as the terminal's `INT` signal. Without
an explicit handler, the standalone Maven JVM does not follow its normal
interrupt termination path and Maven's shutdown hooks do not run, which
can leave long-running child processes alive.

This change registers an `INT` handler for Windows terminals that exits
with status `130`. This triggers normal JVM shutdown and its registered
cleanup hooks.

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

✅ Clean and complete backport of #12538 to maven-4.0.x.

The cherry-pick faithfully reproduces the Ctrl+C signal handler fix with correct conflict resolution preserving the ProjectBuildLogAppender ordering specific to the maven-4.0.x branch.

Key observations:

  • All three changes from the original PR are correctly applied: the org.jline.utils.OSUtils import, the SIGINT_EXIT_CODE = 130 constant, and the Terminal.Signal.INT handler guarded by OSUtils.IS_WINDOWS && !context.invokerRequest.embedded().
  • The conflict resolution is correct — on maven-4.0.x, the ProjectBuildLogAppender block is positioned before MessageUtils.systemInstall(), whereas on master it comes after. The backport preserves the maven-4.0.x ordering, which is the right approach since the ordering difference is pre-existing and unrelated to this fix.
  • The signal handler is self-contained and does not interact with the ProjectBuildLogAppender positioning, so no functional difference arises from the ordering variance between branches.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of gnodet

gnodet added a commit to gnodet/maven that referenced this pull request Jul 27, 2026
@gnodet
gnodet merged commit 0044d16 into maven-4.0.x Jul 27, 2026
24 checks passed
@gnodet
gnodet deleted the backport-12538-to-maven-4.0.x branch July 27, 2026 22:41
@github-actions github-actions Bot added this to the 4.0.0-rc-6 milestone Jul 27, 2026
@github-actions

Copy link
Copy Markdown

@gnodet Please assign appropriate label to PR according to the type of change.

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.

2 participants