diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-09-02 16:09:19 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-02 16:09:19 +0300 |
| commit | d08e44686d8b19bd9555cc99ec9068d9fde05f16 (patch) | |
| tree | ca2f34d2117efbf770095c437f9d6402c24d9fb3 /src/platform/mod.rs | |
| parent | 8633a398e653eee47b375c963996c78a8a14aa48 (diff) | |
fix(client): detach when terminal geometry is unavailable (#3531)
refs #3519
Diffstat (limited to 'src/platform/mod.rs')
| -rw-r--r-- | src/platform/mod.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/platform/mod.rs b/src/platform/mod.rs index fc80bc64..b831e120 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -69,6 +69,23 @@ pub(crate) const fn capabilities() -> PlatformCapabilities { } } +pub(crate) fn terminal_grid_size() -> std::io::Result<(u16, u16)> { + #[cfg(unix)] + let (cols, rows) = unix_common::read_terminal_grid_size()?; + #[cfg(windows)] + let (cols, rows) = windows::read_terminal_grid_size()?; + #[cfg(not(any(unix, windows)))] + let (cols, rows) = fallback::read_terminal_grid_size()?; + + if cols == 0 || rows == 0 { + return Err(std::io::Error::new( + std::io::ErrorKind::InvalidData, + "terminal reported a zero-sized grid", + )); + } + Ok((cols, rows)) +} + #[cfg(not(windows))] pub fn launch_server_daemon_command(command: &mut std::process::Command) -> std::io::Result<u32> { command.spawn().map(|child| child.id()) |
