GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix #12536: Handle Ctrl+C on Windows terminals by JackMyers001 · Pull Request #12538 · apache/maven

Conversation

@JackMyers001

@JackMyers001 JackMyers001 commented Jul 24, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Summary

Fixes #12536.

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.

Please backport this change to maven-4.0.x.

Testing

  • mvn -Prun-its verify passes
  • Confirmed issue in 4.0.0-rc-5 and master on:
    • Windows 11 with PowerShell in Windows Terminal
    • Windows 11 with Git Bash in Windows Terminal
  • Confirmed issue is not present in 4.0.0-rc-5 and master on:
    • macOS 26 with Fish in Ghostty
    • Arch Linux with Fish in Ghostty
  • Confirmed issue is not present in 3.9.16 on all configs listed above
  • Confirmed issue is not present with this patch on all configs listed above

No automated regression test is included because the failure requires a real Windows terminal running Maven and a way to send a Ctrl+C event to that console.

Checklist

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
    Note that commits might be squashed by a maintainer on merge.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
    This may not always be possible but is a best-practice.
  • Run mvn verify to make sure basic checks pass.
    A more thorough check will be performed on your pull request automatically.
  • You have run the Core IT successfully.

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

  • I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
  • In any other case, please file an Apache Individual Contributor License Agreement.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@JackMyers001
Fix apache#12536: Handle Ctrl+C on Windows terminals
5fe8870
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 approved these changes Jul 24, 2026
View reviewed changes

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Code Review

Clean, minimal, and correctly scoped fix for a real Windows-specific Ctrl+C regression in Maven 4. The approach is sound and consistent with existing codebase patterns.

Key observations:

  • The !context.invokerRequest.embedded() guard is essential and correctly placed — calling System.exit() from an embedded Maven invocation would terminate the host process. The doCreateTerminal method already uses the same embedded() check.
  • Exit code 130 (128 + SIGINT=2) follows the Unix convention for signal-terminated processes and is properly extracted into a named constant.
  • The fix is correctly gated to Windows only via OSUtils.IS_WINDOWS. On Unix/macOS, the OS delivers SIGINT to the JVM natively. On Windows, JLine puts the terminal into raw mode and consumes Ctrl+C as console input before the JVM sees it.
  • System.exit() is appropriate here (vs. Thread.currentThread().interrupt() used in other handlers like EncryptInvoker/ShellInvoker) because the goal is full JVM termination with shutdown hooks for the main build invocation.

Two minor notes (non-blocking):

  • The signal handler runs inside the terminalConsumer callback on the fast-terminal-thread — the handler is correctly registered on the real underlying terminal.
  • The lambda parameter signal is unused (always INT), consistent with existing patterns in EncryptInvoker, UpgradeInvoker, and ShellInvoker.

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

Claude Code on behalf of gnodet

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gnodet gnodet added this to the 4.0.0-rc-6 milestone Jul 24, 2026
@gnodet
gnodet merged commit a3e576b into apache:master Jul 27, 2026
22 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@gnodet gnodet mentioned this pull request Jul 27, 2026
Backport #12538: Handle Ctrl+C on Windows terminals #12550
Merged
@github-actions github-actions Bot assigned gnodet Jul 27, 2026
@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gnodet gnodet mentioned this pull request Jul 27, 2026
Deps: Bump to Eclipse Sisu 1.1.0 #12551
Closed
gnodet added a commit that referenced this pull request Jul 27, 2026
@gnodet
Fix #12536: Handle Ctrl+C on Windows terminals
0044d16
Backport of #12538. 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) to
restore proper Ctrl+C behavior, guarded by IS_WINDOWS and !embedded().

Closes #12550
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gnodet gnodet gnodet approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@gnodet gnodet

Labels

None yet

Projects

None yet

Milestone

4.0.0-rc-6

Development

Successfully merging this pull request may close these issues.

Maven 4 - Ctrl+C does not terminate child processes on Windows

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@JackMyers001 @gnodet
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.