Skip to content

kernel: Restore prim_tty signals option to pass control bytes through in raw mode - #11514

Open
gilbertwong96 wants to merge 1 commit into
erlang:masterfrom
gilbertwong96:prim_tty_signals_option
Open

kernel: Restore prim_tty signals option to pass control bytes through in raw mode#11514
gilbertwong96 wants to merge 1 commit into
erlang:masterfrom
gilbertwong96:prim_tty_signals_option

Conversation

@gilbertwong96

@gilbertwong96 gilbertwong96 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Fixes #11512.

Expose the fix in the public API instead of the internal prim_tty module:
shell:start_interactive({noshell, #{mode => raw, signals => false}}) now
disables the terminal driver's signal and flow control handling in raw
mode, so control bytes (ctrl+o, ctrl+c, ctrl+s/q) reach the application
as data. The option is passed down through user_drv to prim_tty and can
be switched on and off at runtime. On Windows, ENABLE_PROCESSED_INPUT is
cleared.

The test runs a noshell peer on a run_erl pty and verifies that ctrl+o is
delivered, then swallowed, then delivered again as the option is toggled.

@github-actions

github-actions Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

CT Test Results

    5 files    288 suites   3h 1m 24s ⏱️
5 523 tests 5 000 ✅ 520 💤 3 ❌
6 900 runs  6 294 ✅ 603 💤 3 ❌

For more details on these failures, see this check.

Results for commit f6d030c.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@garazdawi

Copy link
Copy Markdown
Member

Hello! Thanks for the pr!

prim_tty is an undocumented internal module, so there are no guarantees that it will retain functionality or be backwards compatible in any way. So this API needs to be added in a public module somewhere. I propose that we expand shell:start_interactive/1 to include it. Something like:

-spec start_interactive(noshell | {noshell, raw | cooked | #{ mode => raw | cooked, signals => boolean()}} | {module(), atom(), [term()]}) ->
          ok | {error, already_started};

and then pass that option all the way down to prim_tty. The code should also be able to handle that we switch the option on and off again, so the tests should check that that is possible.

Also windows needs to be handled as well and there it is the ENABLE_PROCESSED_INPUT flag that needs to be cleared.

As this is a new API it will not be patched into older versions, but released in the next feature release.

In the future, if you find that you need to use some internal module, please create an issue and let us know so that we can create a public API for it so that it does not get lost.

@gilbertwong96
gilbertwong96 force-pushed the prim_tty_signals_option branch from 25a4cfc to f6d030c Compare August 21, 2026 03:35
@gilbertwong96
gilbertwong96 changed the base branch from maint-28 to master August 21, 2026 03:35
@gilbertwong96

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I've reworked the PR along these lines:

  • The option is now exposed via shell:start_interactive/1 as {noshell, #{mode => raw, signals => false}}, with signals => boolean() defaulting to true; the old {noshell, raw | cooked} forms still work.
  • It is passed down through user_drv to prim_tty, and the test verifies it can be switched on and off at runtime (ctrl+o delivered -> swallowed -> delivered again).
  • Windows is handled: ENABLE_PROCESSED_INPUT is cleared when signals => false.
  • The test runs in the to_erl group (run_erl pty) since prim_tty is not part of the public API anymore.

The PR is now based on master since this is a new API.

shell:start_interactive/1 can now take {noshell, #{mode => raw,
signals => false}} to disable the terminal driver's signal and flow
control handling in raw mode, so that control bytes such as ctrl+s/q,
ctrl+c and ctrl+o are passed to the application as data instead of
being intercepted. The option is passed through user_drv to prim_tty
and can be switched on and off at runtime. On Windows,
ENABLE_PROCESSED_INPUT is cleared when signals is false.

This restores the prim_tty sig option that was dropped in the OTP 28
shell improvements.
@gilbertwong96
gilbertwong96 force-pushed the prim_tty_signals_option branch from f6d030c to 805f6a9 Compare August 21, 2026 05:49
@IngelaAndin IngelaAndin added the team:VM Assigned to OTP team VM label Aug 24, 2026
@jhogberg jhogberg added the testing currently being tested, tag is used by OTP internal CI label Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI

Projects

None yet

4 participants