Skip to content

feat: change default of softwareSignals to false and deprecate#2020

Open
gnodet wants to merge 4 commits into
jline:masterfrom
gnodet:implement-1960
Open

feat: change default of softwareSignals to false and deprecate#2020
gnodet wants to merge 4 commits into
jline:masterfrom
gnodet:implement-1960

Conversation

@gnodet

@gnodet gnodet commented Jun 30, 2026

Copy link
Copy Markdown
Member

Fix #1960

Changes the default of org.jline.terminal.softwareSignals from true to false and deprecates the property for eventual removal.

Changes

  • Default changed: PROP_SOFTWARE_SIGNALS now defaults to false in both AbstractUnixSysTerminal and PosixSysTerminal.

  • Property deprecated: PROP_SOFTWARE_SIGNALS is marked @Deprecated(since = "4.4.0", forRemoval = true) with Javadoc explaining the migration paths.

  • Test added: testDefaultSoftwareSignalsDisabled verifies that when the property is unset, no software signal interception occurs (the VINTR byte is delivered without raising Signal.INT).

  • RawModeExample updated: demonstrates how to handle Ctrl+C in a raw-mode input loop by reading the VINTR character from terminal attributes via getControlChar(ControlChar.VINTR).

Migration

Applications that relied on terminal.handle(Signal.INT, ...) in raw mode should migrate to one of:

  1. Set the property explicitly-Dorg.jline.terminal.softwareSignals=true restores the old behavior temporarily.
  2. LineReader's INTERRUPT widget — Ctrl+C throws UserInterruptException from readLine() (see SimpleLineReadingExample).
  3. Handle the VINTR byte directly — read the interrupt character from terminal attributes and handle it in your own input loop (see RawModeExample).

Summary by CodeRabbit

  • Bug Fixes
    • Changed the default behavior of software signal interception so it remains disabled when the related property is unset.
    • Updated raw-mode interrupt expectations so Ctrl+C (VINTR) is handled explicitly by applications.
  • New Features
    • Enhanced the raw-mode example to detect Ctrl+C and exit cleanly.
  • Tests
    • Added coverage to confirm the default software-signal behavior is disabled when the property is not set.
  • Documentation
    • Refreshed Javadoc to clarify defaults and provide raw-mode migration guidance.
  • Deprecations
    • Marked the software-signal property as deprecated for removal.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ebe9704a-c479-4e75-8804-42e786b980b6

📥 Commits

Reviewing files that changed from the base of the PR and between ac29db4 and af3fc9a.

📒 Files selected for processing (1)
  • demo/src/main/java/org/jline/demo/examples/RawModeExample.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • demo/src/main/java/org/jline/demo/examples/RawModeExample.java

📝 Walkthrough

Walkthrough

This PR deprecates PROP_SOFTWARE_SIGNALS, changes its default from true to false in Unix terminal constructors, updates the raw-mode guidance, adds a test for the new default, and updates the demo example to handle Ctrl+C directly.

Changes

Software Signals Default Change

Layer / File(s) Summary
Deprecate PROP_SOFTWARE_SIGNALS constant and documentation
terminal/src/main/java/org/jline/terminal/TerminalBuilder.java
PROP_SOFTWARE_SIGNALS is marked deprecated-for-removal, and its Javadoc now describes the false default plus migration options for raw-mode signal handling.
Flip default value in terminal constructors
terminal/src/main/java/org/jline/terminal/impl/AbstractUnixSysTerminal.java, terminal/src/main/java/org/jline/terminal/impl/PosixSysTerminal.java
The Boolean.parseBoolean fallback for PROP_SOFTWARE_SIGNALS changes from "true" to "false", and the warning suppressions include "removal".
Test disabled-by-default behavior
terminal/src/test/java/org/jline/terminal/impl/PosixSysTerminalTest.java
Adds warning suppression and a test that clears PROP_SOFTWARE_SIGNALS, feeds VINTR, and asserts no software signal is recorded.
Update raw-mode example for Ctrl+C
demo/src/main/java/org/jline/demo/examples/RawModeExample.java
The example reads VINTR before raw mode, updates the prompt, and exits when Ctrl+C is received as a raw byte.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • jline/jline3#1959: Both PRs change the PROP_SOFTWARE_SIGNALS-controlled software signal interception behavior in Unix and Posix terminals.
  • jline/jline3#1987: Also changes PROP_SOFTWARE_SIGNALS behavior in PosixSysTerminal, overlapping with the default switch in this PR.

Suggested labels: enhancement

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: flipping softwareSignals default to false and deprecating it.
Linked Issues check ✅ Passed The PR changes the default to false, deprecates the property, adds a regression test, and documents migration paths as requested.
Out of Scope Changes check ✅ Passed The example and warning-suppression updates support the same feature and documentation work, with no clear unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

This PR changes the default behavior of JLine’s system terminals regarding software interception of signal control characters by making org.jline.terminal.softwareSignals default to false, and it deprecates the property to guide applications toward native/raw-byte handling (or LineReader’s INTERRUPT widget) going forward.

Changes:

  • Changed the default value for PROP_SOFTWARE_SIGNALS from "true" to "false" in AbstractUnixSysTerminal and PosixSysTerminal.
  • Deprecated TerminalBuilder.PROP_SOFTWARE_SIGNALS with updated Javadoc explaining the migration path.
  • Added a regression test verifying that when the property is unset, 0x03 is delivered as a byte and does not raise Signal.INT.

Reviewed changes

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

File Description
terminal/src/test/java/org/jline/terminal/impl/PosixSysTerminalTest.java Adds a new test to confirm the default disables software signal interception when the property is unset.
terminal/src/main/java/org/jline/terminal/TerminalBuilder.java Deprecates PROP_SOFTWARE_SIGNALS and documents the new default and migration guidance.
terminal/src/main/java/org/jline/terminal/impl/PosixSysTerminal.java Switches the softwareSignals default from "true" to "false" when reading the system property.
terminal/src/main/java/org/jline/terminal/impl/AbstractUnixSysTerminal.java Switches the softwareSignals default from "true" to "false" when reading the system property.

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

@gnodet gnodet marked this pull request as ready for review July 7, 2026 14:26

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
terminal/src/main/java/org/jline/terminal/TerminalBuilder.java (1)

180-202: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider forRemoval = true on @Deprecated.

The Javadoc states removal is planned, but the annotation itself doesn't set forRemoval. Using @Deprecated(since = "4.4.0", forRemoval = true) makes this machine-checkable (IDEs/build tools flag call sites more prominently) rather than relying solely on prose.

♻️ Suggested tweak
-    `@Deprecated`
+    `@Deprecated`(since = "4.4.0", forRemoval = true)
     `@SuppressWarnings`("java:S1133") // Intentional deprecation; removal planned for a future major version
     public static final String PROP_SOFTWARE_SIGNALS = "org.jline.terminal.softwareSignals";
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@terminal/src/main/java/org/jline/terminal/TerminalBuilder.java` around lines
180 - 202, The deprecation on PROP_SOFTWARE_SIGNALS should be made
machine-checkable to match the Javadoc’s removal notice. Update the `@Deprecated`
annotation on TerminalBuilder.PROP_SOFTWARE_SIGNALS to include since and
forRemoval metadata so tools and IDEs flag usage more strongly, while keeping
the existing warning text and suppression unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@terminal/src/main/java/org/jline/terminal/TerminalBuilder.java`:
- Around line 180-202: The deprecation on PROP_SOFTWARE_SIGNALS should be made
machine-checkable to match the Javadoc’s removal notice. Update the `@Deprecated`
annotation on TerminalBuilder.PROP_SOFTWARE_SIGNALS to include since and
forRemoval metadata so tools and IDEs flag usage more strongly, while keeping
the existing warning text and suppression unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f10364da-1771-46a4-ab36-c0b9d3e8fae0

📥 Commits

Reviewing files that changed from the base of the PR and between 6b83c24 and 98ed3bf.

📒 Files selected for processing (4)
  • terminal/src/main/java/org/jline/terminal/TerminalBuilder.java
  • terminal/src/main/java/org/jline/terminal/impl/AbstractUnixSysTerminal.java
  • terminal/src/main/java/org/jline/terminal/impl/PosixSysTerminal.java
  • terminal/src/test/java/org/jline/terminal/impl/PosixSysTerminalTest.java

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
demo/src/main/java/org/jline/demo/examples/RawModeExample.java (1)

49-65: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optional: consolidate loop exit points (SonarCloud S135).

The loop now has two break statements (interrupt byte and q/Q). SonarCloud flags this as a maintainability smell. Not a compiler warning, so it won't trip -Werror, but consolidating avoids a new code-smell finding.

♻️ Optional consolidation
-            while (true) {
+            boolean quit = false;
+            while (!quit) {
                 int c = reader.read(100);
                 if (c != -1) {
                     if (c == intrChar) {
                         terminal.writer().println("Interrupt received (Ctrl+C) — exiting.");
                         terminal.writer().flush();
-                        break;
+                        quit = true;
+                        continue;
                     }

                     terminal.writer().println("Read: " + (char) c + " (ASCII: " + c + ")");
                     terminal.writer().flush();

                     if (c == 'q' || c == 'Q') {
-                        break;
+                        quit = true;
                     }
                 }
             }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@demo/src/main/java/org/jline/demo/examples/RawModeExample.java` around lines
49 - 65, The while loop in RawModeExample’s main read loop has multiple exit
points that trigger SonarCloud S135. Consolidate the loop termination logic in
the read loop around the reader.read(100) handling so there is only one break
path, using the existing intrChar and q/Q checks to set a single exit condition
before breaking.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@demo/src/main/java/org/jline/demo/examples/RawModeExample.java`:
- Around line 49-65: The while loop in RawModeExample’s main read loop has
multiple exit points that trigger SonarCloud S135. Consolidate the loop
termination logic in the read loop around the reader.read(100) handling so there
is only one break path, using the existing intrChar and q/Q checks to set a
single exit condition before breaking.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d9849059-3dce-4816-9052-540580f7b802

📥 Commits

Reviewing files that changed from the base of the PR and between 3a2af91 and ac29db4.

📒 Files selected for processing (2)
  • demo/src/main/java/org/jline/demo/examples/RawModeExample.java
  • terminal/src/main/java/org/jline/terminal/TerminalBuilder.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • terminal/src/main/java/org/jline/terminal/TerminalBuilder.java

@sonarqubecloud

sonarqubecloud Bot commented Jul 7, 2026

Copy link
Copy Markdown

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.

Change default of org.jline.terminal.softwareSignals to false

2 participants