diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm index d168293ee4..6cdf65304d 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm @@ -1034,7 +1034,10 @@ (define (fall-back) (fall-back))) (lambda 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: + ;; . + (if (or (= errno ENOTTY) (= errno EINVAL)) (fall-back) (apply throw args)))))) diff --git a/tests/syscalls.scm b/tests/syscalls.scm index 895f90f4d8..71bcbc4d32 100644 --- a/tests/syscalls.scm +++ b/tests/syscalls.scm @@ -259,15 +259,16 @@ (define perform-container-tests? (#f #f) (lo (interface-address lo))))))) -(test-equal "terminal-window-size ENOTTY" - ENOTTY +(test-assert "terminal-window-size ENOTTY" (call-with-input-file "/dev/null" (lambda (port) (catch 'system-error (lambda () (terminal-window-size port)) (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" (> (terminal-columns) 0))