Repository navigation
Tests: leave the macOS PENDIN flag out of terminal-mode comparisons - #254
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Test code only. Terminal-mode comparisons in the tests no longer include the macOS
PENDINlocal flag.Why
macOS sets
PENDINwhenever 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_modeintests/pty_signals.rsand in the test module ofsrc/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 onlyPENDINmasked inc_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.is_restored, the SIGINT restore check, the job-control round, the fatal probe). The older helperterminal_state_restored, which already did this for the thread-start probes, is replaced by it.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 inPENDINonly. It does not require the kernel to set the flag.raw_terminal_mode_comparison_ignores_only_pendin, synthetic: aPENDIN-only difference is equal;PENDINplus one raw control bit nix does not name is different;ECHOalone is different.Checks
cargo clippy --all-targets --target x86_64-unknown-linux-gnu -- -D warningspasses.No product change, no release.