emacs-bug-tracker
[Top][All Lists]
Advanced

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

bug#57730: closed ([PATCH] syscalls: Adjust for glibc 2.34 and later.)


From: GNU bug Tracking System
Subject: bug#57730: closed ([PATCH] syscalls: Adjust for glibc 2.34 and later.)
Date: Mon, 07 Nov 2022 21:31:01 +0000

Your message dated Mon, 07 Nov 2022 22:30:20 +0100
with message-id <87r0yesb9v.fsf_-_@gnu.org>
and subject line Re: bug#57730: [PATCH] syscalls: Adjust for glibc 2.34 and 
later.
has caused the debbugs.gnu.org bug report #57730,
regarding [PATCH] syscalls: Adjust for glibc 2.34 and later.
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
57730: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=57730
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: [PATCH] syscalls: Adjust for glibc 2.34 and later. Date: Sun, 11 Sep 2022 12:50:51 +0200
This is a re-implementation of 3c8b6fd94ceb1e898216929e8768fb518dbf1de9 that
works with new and old libc's.

* guix/build/syscalls.scm (openpty, login-tty): Wrap in exception handlers and
retry with libutil if the first call is unsuccessful.
---
 guix/build/syscalls.scm | 71 ++++++++++++++++++++++++++---------------
 1 file changed, 45 insertions(+), 26 deletions(-)

diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index b00615d9b7..eee90216eb 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -9,6 +9,7 @@
 ;;; Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
 ;;; Copyright © 2021 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2022 Oleg Pykhalov <go.wigust@gmail.com>
+;;; Copyright © 2022 Marius Bakke <marius@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -2339,39 +2340,57 @@ (define* (terminal-rows #:optional (port 
(current-output-port)))
   (terminal-dimension window-size-rows port (const 25)))
 
 (define openpty
-  (let ((proc (syscall->procedure int "openpty" '(* * * * *)
-                                  #:library "libutil")))
-    (lambda ()
-      "Return two file descriptors: one for the pseudo-terminal control side,
+  (lambda* (#:optional library)
+    "Return two file descriptors: one for the pseudo-terminal control side,
 and one for the controlled side."
+    (let ((proc (syscall->procedure int "openpty" '(* * * * *)
+                                    #:library library)))
       (let ((head     (make-bytevector (sizeof int)))
             (inferior (make-bytevector (sizeof int))))
-        (let-values (((ret err)
-                      (proc (bytevector->pointer head)
-                            (bytevector->pointer inferior)
-                            %null-pointer %null-pointer %null-pointer)))
-          (unless (zero? ret)
-            (throw 'system-error "openpty" "~A"
-                   (list (strerror err))
-                   (list err))))
-
-        (let ((* (lambda (bv)
-                   (bytevector-sint-ref bv 0 (native-endianness)
-                                        (sizeof int)))))
-          (values (* head) (* inferior)))))))
+        (catch 'system-error
+          (lambda ()
+            (let-values (((ret err)
+                          (proc (bytevector->pointer head)
+                                (bytevector->pointer inferior)
+                                %null-pointer %null-pointer %null-pointer)))
+              (unless (zero? ret)
+                (throw 'system-error "openpty" "~A"
+                       (list (strerror err))
+                       (list err)))
+
+              (let ((* (lambda (bv)
+                         (bytevector-sint-ref bv 0 (native-endianness)
+                                              (sizeof int)))))
+                (values (* head) (* inferior)))))
+          (lambda args
+            (if (and (= (system-error-errno args) 38)
+                     (not library))
+                ;; Prior to glibc 2.34, openpty resided in libutil.
+                ;; Try again, fingers crossed!
+                (openpty "libutil")
+                (apply throw args))))))))
 
 (define login-tty
-  (let* ((proc (syscall->procedure int "login_tty" (list int)
-                                   #:library "libutil")))
-    (lambda (fd)
-      "Make FD the controlling terminal of the current process (with the
+  (lambda* (fd #:optional library)
+    "Make FD the controlling terminal of the current process (with the
 TIOCSCTTY ioctl), redirect standard input, standard output and standard error
 output to this terminal, and close FD."
-      (let-values (((ret err) (proc fd)))
-        (unless (zero? ret)
-          (throw 'system-error "login-pty" "~A"
-                 (list (strerror err))
-                 (list err)))))))
+    (let ((proc (syscall->procedure int "login_tty" (list int)
+                                    #:library library)))
+      (catch 'system-error
+        (lambda ()
+          (let-values (((ret err) (proc fd)))
+            (unless (zero? ret)
+              (throw 'system-error "login-pty" "~A"
+                     (list (strerror err))
+                     (list err)))))
+        (lambda args
+          (if (and (= (system-error-errno args) 38)
+                   (not library))
+              ;; Prior to glibc 2.34, login-pty resided in libutil.
+              ;; Try again, fingers crossed!
+              (login-tty fd "libutil")
+              (apply throw args)))))))
 
 
 ;;;
-- 
2.37.3




--- End Message ---
--- Begin Message --- Subject: Re: bug#57730: [PATCH] syscalls: Adjust for glibc 2.34 and later. Date: Mon, 07 Nov 2022 22:30:20 +0100 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Hi,

Mathieu Othacehe <othacehe@gnu.org> skribis:

> Hey,
>
>> Can you commit it, or should I do it on your behalf?  I think we should
>> try to get it in 1.4.0 so Guix works when linked against system libc on
>> foreign distributions.
>
> This indeed seems like the right thing to do :) Marius or Ludo, I think
> you can go ahead :)

Pushed on ‘core-updates’ as 3f6c32a88fc7a4d707ae1ed8ef3f7bd995461aff!

Ludo’.


--- End Message ---

reply via email to

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