Skip to content

Tests: leave the macOS PENDIN flag out of terminal-mode comparisons - #254

Merged
inxbit merged 2 commits into
mainfrom
test/pendin-termios-compare
Dec 5, 2026
Merged

inxbit merged 2 commits into
mainfrom
test/pendin-termios-compare

Conversation

@inxbit

@inxbit inxbit commented Dec 5, 2026 •

Copy link
Copy Markdown
Owner

What

Test code only. Terminal-mode comparisons in the tests no longer include the macOS PENDIN local flag.

Why

macOS sets PENDIN whenever a terminal returns from raw to canonical mode and clears it at the next read or poll of the terminal. It is kernel state, not a setting a program saved. After a fault or abort signal PrismTTY restores the saved mode and ends at once, so nothing reads the terminal, and a test that compares the whole mode can see the flag. At the 1.6.9 release a gate with the same strict comparison failed in 2 of 10 fatal-signal rows for that bit alone, on a binary that had passed all rows an hour earlier.

Change

  • same_terminal_mode in tests/pty_signals.rs and in the test module of src/cli/pty.rs: on macOS it compares the seven raw fields of the mode (c_iflag, c_oflag, c_cflag, c_lflag, c_cc, c_ispeed, c_ospeed) with only PENDIN masked in c_lflag; on other systems it is plain equality. The raw fields are used because nix keeps only the flag bits it names for macOS in its public fields.
  • Used at the four comparison sites (is_restored, the SIGINT restore check, the job-control round, the fatal probe). The older helper terminal_state_restored, which already did this for the thread-start probes, is replaced by it.
  • New macOS test restored_terminal_mode_ignores_kernel_pendin: on a fresh PTY, raw then back; the helper says equal, and if full equality differs, the local flags differ in PENDIN only. It does not require the kernel to set the flag.
  • New macOS test raw_terminal_mode_comparison_ignores_only_pendin, synthetic: a PENDIN-only difference is equal; PENDIN plus one raw control bit nix does not name is different; ECHO alone is different.

Checks

  • Full local gate on macOS: fmt, clippy, all Rust tests, node tests, privacy scan pass.
  • cargo clippy --all-targets --target x86_64-unknown-linux-gnu -- -D warnings passes.
  • The fatal-signal test and the two new tests: 10 of 10 runs pass.

No product change, no release.

macOS sets PENDIN in the local flags whenever a terminal returns from raw to canonical mode and clears it at the next read or poll. After a fault or abort signal PrismTTY restores the mode and ends at once, so a test that compares the whole mode can see the flag and fail under load. One helper per test file compares the modes without that flag on macOS and stays plain equality elsewhere; a macOS test pins the kernel behavior.
nix keeps only the flag bits it names for macOS in its public fields, and its speed getters rewrite the raw value from them. The helpers now compare the seven raw fields of the mode, with PENDIN masked in the local flags, so nothing else that full equality saw is left out. A synthetic test shows a PENDIN-only difference is equal, and one more raw bit or ECHO is not.
@inxbit
inxbit marked this pull request as ready for review December 5, 2026 01:00
@inxbit
inxbit merged commit e6aa5d6 into main Dec 5, 2026
6 checks passed
@inxbit
inxbit deleted the test/pendin-termios-compare branch December 5, 2026 01:00
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.

1 participant