-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
stty: verify tcsetattr applied all settings #10569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
stty: verify tcsetattr applied all settings #10569
Conversation
|
Just for doing some local tests to validate, do you have some testing commands that you used to compare the gnu behavior? Would it be possible to add an integration test for this as well? |
|
GNU testsuite comparison: |
|
Thanks for the review! I've added an integration test in the latest commit. Testing Commands (GNU vs uutils comparison)The issue is that POSIX allows # GNU stty - after tcsetattr, it reads back and compares with eq_mode()
# If settings don't match, exits with: "<device>: unable to perform all requested operations"
# Test setting multiple values at once:
stty -F /dev/pts/0 intr ^A quit ^B erase ^H
stty -F /dev/pts/0 # Verify all three are setAbout the integration testI added
This tests the normal success path of the verification logic. Note: Triggering an actual partial |
|
GNU testsuite comparison: |
26e9c96 to
f5ba572
Compare
|
GNU testsuite comparison: |
|
A bunch of tests are failing |
|
GNU testsuite comparison: |
8e457a8 to
b2388fb
Compare
|
GNU testsuite comparison: |
POSIX allows tcsetattr() to return success while only partially applying the requested settings. This change adds verification by reading back the terminal settings after tcsetattr() and comparing them with the requested configuration. If the settings don't match, stty now exits with an error message: "<device>: unable to perform all requested operations" This matches GNU stty behavior, which uses tcgetattr() after setting and compares with eq_mode() to detect partial application. Changes: - Added verify_termios_changes() function to compare termios structs - Uses from_bits_truncate() to normalize flags for portable comparison - Only verifies fields that were actually changed (requested != original) - Added integration test for multiple settings verification Fixes uutils#10324
Saved states may contain platform-specific flags that can't be perfectly restored on all systems. Skip verification for saved state restoration since it's inherently 'best effort' - users expect it to work across platforms even if not every flag can be set.
These are termios control flag field names (c_cflag and c_lflag) used in the stty verification code.
3841f58 to
9f1af77
Compare
|
GNU testsuite comparison: |
|
The failing test ( Could a maintainer please re-run the failed job? Thanks! |
|
Still seeing flaky ARM failures, now a different test: This is a These ARM CI flakes seem systemic. Could a maintainer re-run or advise? |
Summary
Fixes #10324
POSIX allows
tcsetattr()to return success while only partially applying the requested settings:This PR adds verification by reading back terminal settings after
tcsetattr()and comparing them with the requested configuration.Changes
termios_eq()function to compare twoTermiosstructs (flags, control characters, and baud rates)tcsetattr(), calltcgetattr()and verify settings matchTesting
All existing tests pass (
cargo test -p uu_stty).This matches GNU stty behavior, which performs
tcgetattr()after setting and useseq_mode()to detect partial application.