syscalls: 'terminal-columns' catches EINVAL on the TIOCGWINSZ ioctl.
Reported by Mark H Weaver <mhw@netris.org>. * guix/build/syscalls.scm (terminal-columns): Tolerate EINVAL. * tests/syscalls.scm ("terminal-window-size ENOTTY"): Likewise.
This commit is contained in:
parent
0054e47036
commit
5cd25aad3c
|
@ -1034,7 +1034,10 @@ always a positive integer."
|
||||||
(fall-back)))
|
(fall-back)))
|
||||||
(lambda args
|
(lambda args
|
||||||
(let ((errno (system-error-errno args)))
|
(let ((errno (system-error-errno args)))
|
||||||
(if (= errno ENOTTY)
|
;; ENOTTY is what we're after but 2012-and-earlier Linux versions
|
||||||
|
;; would return EINVAL instead in some cases:
|
||||||
|
;; <https://bugs.ruby-lang.org/issues/10494>.
|
||||||
|
(if (or (= errno ENOTTY) (= errno EINVAL))
|
||||||
(fall-back)
|
(fall-back)
|
||||||
(apply throw args))))))
|
(apply throw args))))))
|
||||||
|
|
||||||
|
|
|
@ -259,15 +259,16 @@
|
||||||
(#f #f)
|
(#f #f)
|
||||||
(lo (interface-address lo)))))))
|
(lo (interface-address lo)))))))
|
||||||
|
|
||||||
(test-equal "terminal-window-size ENOTTY"
|
(test-assert "terminal-window-size ENOTTY"
|
||||||
ENOTTY
|
|
||||||
(call-with-input-file "/dev/null"
|
(call-with-input-file "/dev/null"
|
||||||
(lambda (port)
|
(lambda (port)
|
||||||
(catch 'system-error
|
(catch 'system-error
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(terminal-window-size port))
|
(terminal-window-size port))
|
||||||
(lambda args
|
(lambda args
|
||||||
(system-error-errno args))))))
|
;; Accept EINVAL, which some old Linux versions might return.
|
||||||
|
(memv (system-error-errno args)
|
||||||
|
(list ENOTTY EINVAL)))))))
|
||||||
|
|
||||||
(test-assert "terminal-columns"
|
(test-assert "terminal-columns"
|
||||||
(> (terminal-columns) 0))
|
(> (terminal-columns) 0))
|
||||||
|
|
Loading…
Reference in New Issue