diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-09-06 02:27:06 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-06 02:27:06 +0300 |
| commit | 9e9bc8a144667a6b7debfd4f0c7a31ff0e11493a (patch) | |
| tree | 03f1259f91fd9edeacfd4b904f2e84d4acf25232 /src/platform/unix_common.rs | |
| parent | 35b0dff96579f099e0436290085024424ffb289c (diff) | |
feat: manage multiple ssh machines from one client (#3670)
Diffstat (limited to 'src/platform/unix_common.rs')
| -rw-r--r-- | src/platform/unix_common.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/platform/unix_common.rs b/src/platform/unix_common.rs index a7926c22..dff67357 100644 --- a/src/platform/unix_common.rs +++ b/src/platform/unix_common.rs @@ -1,5 +1,24 @@ use std::path::{Path, PathBuf}; +pub(crate) fn wait_client_stream_readable(stream: &crate::ipc::LocalStream) -> std::io::Result<()> { + use std::os::fd::{AsFd as _, AsRawFd as _}; + let crate::ipc::LocalStream::UdSocket(stream) = stream; + let mut descriptor = libc::pollfd { + fd: stream.as_fd().as_raw_fd(), + events: libc::POLLIN, + revents: 0, + }; + // Bound cancellation latency without polling idle connections hundreds of times per second. + let result = unsafe { libc::poll(&mut descriptor, 1, 100) }; + if result < 0 { + let error = std::io::Error::last_os_error(); + if error.kind() != std::io::ErrorKind::Interrupted { + return Err(error); + } + } + Ok(()) +} + pub(super) fn read_terminal_grid_size() -> std::io::Result<(u16, u16)> { crossterm::terminal::window_size().map(|size| (size.columns, size.rows)) } |
