-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Implement termios.tcgetwinsize/tcsetwinsize #8347
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
Merged
+56
−4
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d09e9b8
Implement termios.tcgetwinsize/tcsetwinsize
sigmaith 0614732
Use ret < 0 convention for ioctl error checks in termios winsize
sigmaith 2c555e5
Reject non-sequence size in tcsetwinsize
sigmaith 414a869
Use `core::mem::zeroed` instead of `std::mem::zeroed`
sigmaith 8af3f22
Use try_index for tcsetwinsize row/col conversion
sigmaith cbe201b
Mark test_fork/test_spawn_doesnt_hang as expected failures
sigmaith 6888774
Use unittest.skip instead of expectedFailure for pty.fork() tests
sigmaith 0fb01e0
Clarify skip reason for pty.fork() tests
sigmaith 0a94885
Simplify tcgetwinsize/tcsetwinsize fd argument with Fildes destructuring
sigmaith ab4622a
Explain why pty.fork() tests use skip instead of expectedFailure
sigmaith File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Implement termios.tcgetwinsize/tcsetwinsize
Adds ioctl(TIOCGWINSZ/TIOCSWINSZ) wrappers in host_env and the corresponding Python-facing functions in the termios stdlib module, removing the associated expectedFailure markers in test_termios.py. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RbzcYLnX5tMfTM9BP7FDTT
- Loading branch information
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -165,3 +165,27 @@ pub fn tcflush(fd: i32, queue: i32) -> std::io::Result<()> { | |
| pub fn tcflow(fd: i32, action: i32) -> std::io::Result<()> { | ||
| ::termios::tcflow(fd, action) | ||
| } | ||
|
|
||
| pub fn tcgetwinsize(fd: i32) -> std::io::Result<(u16, u16)> { | ||
| let mut size: libc::winsize = unsafe { std::mem::zeroed() }; | ||
| let ret = unsafe { libc::ioctl(fd, TIOCGWINSZ as _, &mut size) }; | ||
| if ret != 0 { | ||
| return Err(std::io::Error::last_os_error()); | ||
| } | ||
| Ok((size.ws_row, size.ws_col)) | ||
| } | ||
|
|
||
| pub fn tcsetwinsize(fd: i32, row: u16, col: u16) -> std::io::Result<()> { | ||
| let mut size: libc::winsize = unsafe { std::mem::zeroed() }; | ||
| let ret = unsafe { libc::ioctl(fd, TIOCGWINSZ as _, &mut size) }; | ||
| if ret != 0 { | ||
| return Err(std::io::Error::last_os_error()); | ||
| } | ||
|
sigmaith marked this conversation as resolved.
Outdated
|
||
| size.ws_row = row; | ||
| size.ws_col = col; | ||
| let ret = unsafe { libc::ioctl(fd, TIOCSWINSZ as _, &size) }; | ||
| if ret != 0 { | ||
| return Err(std::io::Error::last_os_error()); | ||
| } | ||
|
sigmaith marked this conversation as resolved.
Outdated
|
||
| Ok(()) | ||
| } | ||
|
Comment on lines
+178
to
+191
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CPython also calls ioctl twice |
||
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.