guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

07/07: syscalls: 'terminal-columns' catches EINVAL on the TIOCGWINSZ ioc


From: Ludovic Courtès
Subject: 07/07: syscalls: 'terminal-columns' catches EINVAL on the TIOCGWINSZ ioctl.
Date: Mon, 25 Apr 2016 21:35:32 +0000

civodul pushed a commit to branch master
in repository guix.

commit 5cd25aad3cdb6c970a76542e328a3beba8c1f2c9
Author: Ludovic Courtès <address@hidden>
Date:   Mon Apr 25 23:22:45 2016 +0200

    syscalls: 'terminal-columns' catches EINVAL on the TIOCGWINSZ ioctl.
    
    Reported by Mark H Weaver <address@hidden>.
    
    * guix/build/syscalls.scm (terminal-columns): Tolerate EINVAL.
    * tests/syscalls.scm ("terminal-window-size ENOTTY"): Likewise.
---
 guix/build/syscalls.scm |    5 ++++-
 tests/syscalls.scm      |    7 ++++---
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index d168293..6cdf653 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -1034,7 +1034,10 @@ always a positive integer."
           (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:
+        ;; <https://bugs.ruby-lang.org/issues/10494>.
+        (if (or (= errno ENOTTY) (= errno EINVAL))
             (fall-back)
             (apply throw args))))))
 
diff --git a/tests/syscalls.scm b/tests/syscalls.scm
index 895f90f..71bcbc4 100644
--- a/tests/syscalls.scm
+++ b/tests/syscalls.scm
@@ -259,15 +259,16 @@
              (#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))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]