mirror of
https://github.com/alacritty/alacritty.git
synced 2026-12-03 01:58:58 +03:00
Handle PTY non-blocking failure gracefully
We ran in to a application-wide panic from an `assert` in the terminal, this PR makes `set_nonblocking` fallible and propagates the error rather than using an assert.
This commit is contained in:
2 files changed
+7
-3
No files matched your search
@@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
|
||||
## 0.26.1-dev
|
||||
|
||||
### Fixed
|
||||
|
||||
- Panic when the PTY could not be set to non-blocking
|
||||
|
||||
## 0.26.0
|
||||
|
||||
### Added
|
||||
|
||||
@@ -290,7 +290,7 @@ pub fn from_fd(config: &Options, window_id: u64, master: OwnedFd, slave: OwnedFd
|
||||
unsafe {
|
||||
// Maybe this should be done outside of this function so nonblocking
|
||||
// isn't forced upon consumers. Although maybe it should be?
|
||||
set_nonblocking(master_fd);
|
||||
set_nonblocking(master_fd)?;
|
||||
}
|
||||
|
||||
Ok(Pty { child, file: File::from(master), signals, sig_id })
|
||||
@@ -436,9 +436,9 @@ impl ToWinsize for WindowSize {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn set_nonblocking(fd: c_int) {
|
||||
unsafe fn set_nonblocking(fd: c_int) -> Result<()> {
|
||||
let res = unsafe { fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK) };
|
||||
assert_eq!(res, 0);
|
||||
if res == 0 { Ok(()) } else { Err(Error::last_os_error()) }
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user