fix: guard ioctl results with when to avoid partial values

ignore-errors + ioctl can return (values 80 nil) when the fd exists
but isn't a terminal. or propagates partial values, causing nil in
w or h. Wrap with multiple-value-bind + when to filter.
This commit is contained in:
2026-05-14 13:07:55 -04:00
parent 4a86ae3274
commit db07f8c3a7
2 changed files with 16 additions and 6 deletions

View File

@@ -37,9 +37,14 @@
(values (sb-alien:deref winsize 1)
(sb-alien:deref winsize 0)))
(sb-alien:free-alien winsize)))))
(or (ignore-errors (ioctl-size 0))
(ignore-errors
(ioctl-size (sb-sys:fd-stream-fd (backend-output-stream b))))
(or (multiple-value-bind (cols rows) (ignore-errors (ioctl-size 0))
(when (and cols rows (> cols 0) (> rows 0))
(values cols rows)))
(multiple-value-bind (cols rows)
(ignore-errors
(ioctl-size (sb-sys:fd-stream-fd (backend-output-stream b))))
(when (and cols rows (> cols 0) (> rows 0))
(values cols rows)))
(ignore-errors
(let* ((cstr (sb-ext:posix-getenv "COLUMNS"))
(rstr (sb-ext:posix-getenv "LINES"))