guix-commits
[Top][All Lists]
Advanced

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

[shepherd] 02/02: system: 'syscall->procedure' throws ENOSYS for functio


From: Ludovic Courtès
Subject: [shepherd] 02/02: system: 'syscall->procedure' throws ENOSYS for functions not found.
Date: Sat, 23 May 2020 17:27:05 -0400 (EDT)

civodul pushed a commit to branch master
in repository shepherd.

commit 257cf5af85bf21f68f1f806d225a4cdc1a16210f
Author: Ludovic Courtès <address@hidden>
AuthorDate: Sat May 23 18:44:18 2020 +0200

    system: 'syscall->procedure' throws ENOSYS for functions not found.
    
    * modules/shepherd/system.scm.in (syscall->procedure): Throw to
    'system-error instead of calling 'error'.
    (prctl): Remove now unneeded 'if'.
---
 modules/shepherd/system.scm.in | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/modules/shepherd/system.scm.in b/modules/shepherd/system.scm.in
index a003e32..e5ecd1f 100644
--- a/modules/shepherd/system.scm.in
+++ b/modules/shepherd/system.scm.in
@@ -51,8 +51,8 @@ the returned procedure is called."
                           #:return-errno? #t))
     (lambda args
       (lambda _
-        (error (format #f "~a: syscall->procedure failed: ~s"
-                       name args))))))
+        (throw 'system-error name  "~A" (list (strerror ENOSYS))
+               (list ENOSYS))))))
 
 (define %libc-reboot
   ;; libc's 'reboot' function as declared in <sys/reboot.h>.
@@ -106,20 +106,15 @@ ctrlaltdel(8) and see kernel/reboot.c in Linux."
 (define PR_SET_CHILD_SUBREAPER @PR_SET_CHILD_SUBREAPER@)
 
 (define prctl
-  (if (false-if-exception (dynamic-func "prctl" (dynamic-link)))
-      (let ((proc (syscall->procedure long "prctl" (list int int))))
-        (lambda (process operation)
-          "Perform an operation on the given process"
-          (let-values (((result err) (proc process operation)))
-            (if (= -1 result)
-                (throw 'system-error "prctl" "~A"
-                       (list (strerror err))
-                       (list err))
-                result))))
-      (lambda (process operation)
-        ;; Libc lacks 'prctl', as is the case on GNU/Hurd.
-        (throw 'system-error "prctl" "~A" (list strerror ENOSYS)
-               (list ENOSYS)))))
+  (let ((proc (syscall->procedure long "prctl" (list int int))))
+    (lambda (process operation)
+      "Perform an operation on the given process"
+      (let-values (((result err) (proc process operation)))
+        (if (= -1 result)
+            (throw 'system-error "prctl" "~A"
+                   (list (strerror err))
+                   (list err))
+            result)))))
 
 (define (max-file-descriptors)
   "Return the maximum number of open file descriptors allowed."



reply via email to

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