guix-commits
[Top][All Lists]
Advanced

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

[shepherd] 04/04: Define and use 'SFD_NONBLOCK'.


From: Ludovic Courtès
Subject: [shepherd] 04/04: Define and use 'SFD_NONBLOCK'.
Date: Wed, 12 Jul 2023 09:40:47 -0400 (EDT)

civodul pushed a commit to branch master
in repository shepherd.

commit cbca516901c20a7ec08916ad4b2d492b761525c8
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Tue Jul 11 17:49:53 2023 +0200

    Define and use 'SFD_NONBLOCK'.
    
    * configure.ac: Compute and substitute 'SFD_NONBLOCK'.
    * modules/shepherd/system.scm.in (SFD_NONBLOCK): New variable.
    * modules/shepherd.scm (maybe-signal-port): Use it as a 'signalfd'
    argument instead of calling 'non-blocking-port'.
---
 configure.ac                   | 2 ++
 modules/shepherd.scm           | 2 +-
 modules/shepherd/system.scm.in | 2 ++
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 8aaea92..c786aa5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -138,6 +138,7 @@ AC_CHECK_SIZEOF([sigset_t], [], [#include <signal.h>])
 
 AC_MSG_CHECKING([<sys/signalfd.h> and <sys/signal.h> constants])
 AC_COMPUTE_INT([SFD_CLOEXEC], [SFD_CLOEXEC], [#include <sys/signalfd.h>])
+AC_COMPUTE_INT([SFD_NONBLOCK], [SFD_NONBLOCK], [#include <sys/signalfd.h>])
 AC_COMPUTE_INT([SIG_BLOCK], [SIG_BLOCK], [#include <sys/signal.h>])
 AC_COMPUTE_INT([SIG_UNBLOCK], [SIG_UNBLOCK], [#include <sys/signal.h>])
 AC_COMPUTE_INT([SIG_SETMASK], [SIG_SETMASK], [#include <sys/signal.h>])
@@ -148,6 +149,7 @@ SIZEOF_SIGSET_T="$ac_cv_sizeof_sigset_t"
 AC_SUBST([SIZEOF_STRUCT_SIGNALFD_SIGINFO])
 AC_SUBST([SIZEOF_SIGSET_T])
 AC_SUBST([SFD_CLOEXEC])
+AC_SUBST([SFD_NONBLOCK])
 AC_SUBST([SIG_BLOCK])
 AC_SUBST([SIG_UNBLOCK])
 AC_SUBST([SIG_SETMASK])
diff --git a/modules/shepherd.scm b/modules/shepherd.scm
index 1207964..e1e7669 100644
--- a/modules/shepherd.scm
+++ b/modules/shepherd.scm
@@ -70,7 +70,7 @@ socket file at FILE-NAME upon exit of PROC.  Return the 
values of PROC."
 that is not supported."
   (catch 'system-error
     (lambda ()
-      (let ((port (non-blocking-port (signalfd -1 signals))))
+      (let ((port (signalfd -1 signals (logior SFD_CLOEXEC SFD_NONBLOCK))))
         ;; As per the signalfd(2) man page, block SIGNALS.  The tricky bit is
         ;; that SIGNALS must be blocked for all the threads; new threads will
         ;; inherit the signal mask, but we must ensure that neither Guile's
diff --git a/modules/shepherd/system.scm.in b/modules/shepherd/system.scm.in
index a6e5ec7..490e2d1 100644
--- a/modules/shepherd/system.scm.in
+++ b/modules/shepherd/system.scm.in
@@ -35,6 +35,7 @@
             ipv6-only
             pipe2
             SFD_CLOEXEC
+            SFD_NONBLOCK
             signalfd
             consume-signalfd-siginfo
             block-signals
@@ -234,6 +235,7 @@ sigset pointer."
   @SIZEOF_STRUCT_SIGNALFD_SIGINFO@)
 
 (define SFD_CLOEXEC @SFD_CLOEXEC@)
+(define SFD_NONBLOCK @SFD_NONBLOCK@)
 
 (define signalfd
   (let ((proc (syscall->procedure int "signalfd" `(,int * ,int))))



reply via email to

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