guix-commits
[Top][All Lists]
Advanced

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

[shepherd] 02/04: service: Add asserts to ensure a process monitor is ru


From: Ludovic Courtès
Subject: [shepherd] 02/04: service: Add asserts to ensure a process monitor is running.
Date: Sun, 17 Dec 2023 16:57:10 -0500 (EST)

civodul pushed a commit to branch master
in repository shepherd.

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

    service: Add asserts to ensure a process monitor is running.
    
    * modules/shepherd/service.scm (spawn-service-controller):
    Assert (current-process-monitor) is true.
    (monitor-service-process): Likewise.
    
    Co-authored-by: Ludovic Courtès <ludo@gnu.org>
---
 modules/shepherd/service.scm | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 41c6248..f1dd563 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -382,6 +382,10 @@ denoting what the service provides."
 
 (define (spawn-service-controller service)
   "Return a channel over which @var{service} may be controlled."
+  ;; The service controller may eventually call 'monitor-service-process',
+  ;; which expects a running process monitor.
+  (assert (current-process-monitor))
+
   (let ((channel (make-channel)))
     (spawn-fiber
      (lambda ()
@@ -2491,6 +2495,7 @@ while waiting for @var{program} to terminate."
 
 (define (monitor-service-process service pid)
   "Monitor process @var{pid} and notify @var{service} when it terminates."
+  (assert (current-process-monitor))
   (let ((reply (make-channel)))
     (put-message (current-process-monitor)
                  `(await ,pid ,reply))



reply via email to

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