diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2016-04-25 23:22:45 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2016-04-25 23:34:20 +0200 |
| commit | 5cd25aad3cdb6c970a76542e328a3beba8c1f2c9 (patch) | |
| tree | c2edfdb472236ea9145756b7da82ce32174da22e | |
| parent | 0054e47036b13d46f0f026bbc04d19770c2ecbad (diff) | |
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.
| -rw-r--r-- | guix/build/syscalls.scm | 5 | ||||
| -rw-r--r-- | tests/syscalls.scm | 7 |
2 files changed, 8 insertions, 4 deletions
diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm index d168293ee41..6cdf65304d5 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm | |||
| @@ -1034,7 +1034,10 @@ always a positive integer." | |||
| 1034 | (fall-back))) | 1034 | (fall-back))) |
| 1035 | (lambda args | 1035 | (lambda args |
| 1036 | (let ((errno (system-error-errno args))) | 1036 | (let ((errno (system-error-errno args))) |
| 1037 | (if (= errno ENOTTY) | 1037 | ;; ENOTTY is what we're after but 2012-and-earlier Linux versions |
| 1038 | ;; would return EINVAL instead in some cases: | ||
| 1039 | ;; <https://bugs.ruby-lang.org/issues/10494>. | ||
| 1040 | (if (or (= errno ENOTTY) (= errno EINVAL)) | ||
| 1038 | (fall-back) | 1041 | (fall-back) |
| 1039 | (apply throw args)))))) | 1042 | (apply throw args)))))) |
| 1040 | 1043 | ||
diff --git a/tests/syscalls.scm b/tests/syscalls.scm index 895f90f4d8e..71bcbc4d324 100644 --- a/tests/syscalls.scm +++ b/tests/syscalls.scm | |||
| @@ -259,15 +259,16 @@ | |||
| 259 | (#f #f) | 259 | (#f #f) |
| 260 | (lo (interface-address lo))))))) | 260 | (lo (interface-address lo))))))) |
| 261 | 261 | ||
| 262 | (test-equal "terminal-window-size ENOTTY" | 262 | (test-assert "terminal-window-size ENOTTY" |
| 263 | ENOTTY | ||
| 264 | (call-with-input-file "/dev/null" | 263 | (call-with-input-file "/dev/null" |
| 265 | (lambda (port) | 264 | (lambda (port) |
| 266 | (catch 'system-error | 265 | (catch 'system-error |
| 267 | (lambda () | 266 | (lambda () |
| 268 | (terminal-window-size port)) | 267 | (terminal-window-size port)) |
| 269 | (lambda args | 268 | (lambda args |
| 270 | (system-error-errno args)))))) | 269 | ;; Accept EINVAL, which some old Linux versions might return. |
| 270 | (memv (system-error-errno args) | ||
| 271 | (list ENOTTY EINVAL))))))) | ||
| 271 | 272 | ||
| 272 | (test-assert "terminal-columns" | 273 | (test-assert "terminal-columns" |
| 273 | (> (terminal-columns) 0)) | 274 | (> (terminal-columns) 0)) |
