guix-commits
[Top][All Lists]
Advanced

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

[shepherd] 03/03: service: Call ‘terminate-process’ when the PID file do


From: Ludovic Courtès
Subject: [shepherd] 03/03: service: Call ‘terminate-process’ when the PID file doesn’t show up.
Date: Fri, 15 Dec 2023 11:51:16 -0500 (EST)

civodul pushed a commit to branch master
in repository shepherd.

commit d13c0568d02e47fd69f0e5e786dca0a19d2be24c
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Fri Dec 15 17:21:33 2023 +0100

    service: Call ‘terminate-process’ when the PID file doesn’t show up.
    
    * modules/shepherd/service.scm (make-forkexec-constructor): When
    ‘read-pid-file’ returns #f, call ‘terminate-process’ instead of ‘kill’.
    * NEWS: Update.
---
 NEWS                         | 8 ++++++++
 modules/shepherd/service.scm | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 596ef9f..a611863 100644
--- a/NEWS
+++ b/NEWS
@@ -27,6 +27,14 @@ Until now, user code could call (@ (guile) sleep), the core 
Guile binding for
 caused ‘shepherd’ to actually sleep for that time, instead of performing other
 on-going tasks.  ‘sleep’ is now replaced by (@ (fibers) sleep) to avoid that.
 
+** Ensure termination of services that failed to produce a PID file
+
+When a service started with the #:pid-file argument of
+‘make-forkexec-constructor’ or similar would fail to produce its PID file, the
+process that was spawned would be sent SIGTERM.  Now, it is additionally sent
+SIGKILL after ‘default-process-termination-grace-period’ has expired, as is
+the case when using ‘make-kill-destructor’.
+
 ** Do not accidentally wait for Linux kernel thread completion
    (<https://issues.guix.gnu.org/67132>)
 
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 61be309..41c6248 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -1718,7 +1718,7 @@ start."
              (local-output (l10n "PID file '~a' did not show up; \
 terminating process ~a.")
                            pid-file pid)
-             (catch-system-error (kill (- pid) SIGTERM))
+             (terminate-process (- pid) SIGTERM)
              #f)
             ((? integer? pid)
              pid))



reply via email to

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