guix-commits
[Top][All Lists]
Advanced

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

[shepherd] 01/04: shepherd: Make sure ‘with-process-monitor’ covers ever


From: Ludovic Courtès
Subject: [shepherd] 01/04: shepherd: Make sure ‘with-process-monitor’ covers everything needed.
Date: Sun, 17 Dec 2023 16:57:10 -0500 (EST)

civodul pushed a commit to branch master
in repository shepherd.

commit 9be0b7e6fbe3c2e743b5626f4dff7c7bf9becc16
Author: Attila Lendvai <attila.lendvai@gmail.com>
AuthorDate: Sun Dec 17 01:44:24 2023 +0100

    shepherd: Make sure ‘with-process-monitor’ covers everything needed.
    
    Fixes <https://issues.guix.gnu.org/67839>.
    
    * modules/shepherd.scm (main): Switch with-service-registry and
    with-process-monitor.  This way the parameterize of the process monitor 
covers
    everything else.  This fixes the bug that caused `guix system reconfigure` 
to
    hang in certain situations.  Fix proposed by @emixa-d at:
    https://github.com/wingo/fibers/issues/29#issuecomment-1858922276.
    * tests/replacement.sh: Use ‘fork+exec-command’ in #:start and
    add #:stop.  Make sure ‘test’ can be restarted.
    
    Co-authored-by: Ludovic Courtès <ludo@gnu.org>
---
 modules/shepherd.scm | 10 +++++-----
 tests/replacement.sh | 15 ++++++++++++++-
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/modules/shepherd.scm b/modules/shepherd.scm
index efc5517..3303de3 100644
--- a/modules/shepherd.scm
+++ b/modules/shepherd.scm
@@ -450,13 +450,13 @@ fork in the child process."
         ;; because POSIX threads and 'fork' cannot be used together.
         (run-fibers
          (lambda ()
-           (with-service-registry
+           (with-process-monitor
+             (with-service-registry
 
-             ;; Register and start the 'root' service.
-             (register-services (list root-service))
-             (start-service root-service)
+               ;; Register and start the 'root' service.
+               (register-services (list root-service))
+               (start-service root-service)
 
-             (with-process-monitor
                ;; Replace the default 'system*' binding with one that
                ;; cooperates instead of blocking on 'waitpid'.  Replace
                ;; 'primitive-load' (in C as of 3.0.9) with one that does
diff --git a/tests/replacement.sh b/tests/replacement.sh
index 2e93555..76bdcd0 100644
--- a/tests/replacement.sh
+++ b/tests/replacement.sh
@@ -67,7 +67,8 @@ cat > "$rconf"<<EOF
         '(test)
         #:start (lambda _
                    (display "The replacement is starting.\n")
-                   #t)
+                   (fork+exec-command '("$(type -P sleep)" "300")))
+         #:stop (make-kill-destructor)
         #:actions (actions
                    (say-goodbye (lambda _
                                   (call-with-output-file "$stamp"
@@ -95,3 +96,15 @@ $herd stop test
 $herd disable test
 $herd load root "$rconf"
 $herd status test | grep disabled
+
+# Restarting the service from here used to trigger a bug:
+# <https://issues.guix.gnu.org/67839>.
+$herd enable test
+$herd start test
+
+child_pid="$($herd status test | grep Running \
+   | sed '-es/.*Running value is \([0-9]\+\)\./\1/g')"
+kill -0 "$child_pid"
+
+$herd stop test
+if kill -0 "$child_pid"; then false; else true; fi



reply via email to

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