GNU bug report logs - #75829
[PATCH 0/2] Simplify 'user-processes' tear-down

Previous Next

Package: guix-patches;

Reported by: Ludovic Courtès <ludo <at> gnu.org>

Date: Sat, 25 Jan 2025 14:27:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 75829 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: 75829 <at> debbugs.gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH 2/2] services: user-processes: Remove support for
 /etc/shepherd/do-not-kill.
Date: Sat, 25 Jan 2025 15:53:37 +0100
The /etc/shepherd/do-not-kill feature has been unused since commit
c8289690365887ca1dd122645e479a89cf7cd969, which switched from
unionfs (FUSE) to overlayfs.

* gnu/services/shepherd.scm (%do-not-kill-file): Remove.
(user-processes-shepherd-service): In ‘stop’ action, remove
‘kill-except’, ‘omitted-pids’, and ‘lset=’.  Remove conditionals on
‘omitted-pids’ being non-empty.

Change-Id: Id7c6031fc12fd8ff0a3fde955fb01e373751e2d0
---
 gnu/services/shepherd.scm | 46 ++++-----------------------------------
 1 file changed, 4 insertions(+), 42 deletions(-)

diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm
index d4406e9ba9..e64b16b3f3 100644
--- a/gnu/services/shepherd.scm
+++ b/gnu/services/shepherd.scm
@@ -551,11 +551,6 @@ (define (shepherd-service-upgrade live target)
 ;;; User processes.
 ;;;
 
-(define %do-not-kill-file
-  ;; Name of the file listing PIDs of processes that must survive when halting
-  ;; the system.  Typical example is user-space file systems.
-  "/etc/shepherd/do-not-kill")
-
 (define (user-processes-shepherd-service requirements)
   "Return the 'user-processes' Shepherd service with dependencies on
 REQUIREMENTS (a list of service names).
@@ -573,48 +568,15 @@ (define (user-processes-shepherd-service requirements)
          (requirement requirements)
          (start #~(const #t))
          (stop #~(lambda _
-                   (define (kill-except omit signal)
-                     ;; Kill all the processes with SIGNAL except those listed
-                     ;; in OMIT and the current process.
-                     (let ((omit (cons (getpid) omit)))
-                       (for-each (lambda (pid)
-                                   (unless (memv pid omit)
-                                     (false-if-exception
-                                      (kill pid signal))))
-                                 (processes))))
-
-                   (define omitted-pids
-                     ;; List of PIDs that must not be killed.
-                     (if (file-exists? #$%do-not-kill-file)
-                         (map string->number
-                              (call-with-input-file #$%do-not-kill-file
-                                (compose string-tokenize
-                                         (@ (ice-9 rdelim) read-string))))
-                         '()))
-
-                   (define lset= (@ (srfi srfi-1) lset=))
-
                    (display "sending all processes the TERM signal\n")
 
-                   (if (null? omitted-pids)
-                       (begin
-                         ;; Easy: terminate all of them.
-                         (kill -1 SIGTERM)
-                         (sleep #$grace-delay)
-                         (kill -1 SIGKILL))
-                       (begin
-                         ;; Kill them all except OMITTED-PIDS.  XXX: We would
-                         ;; like to (kill -1 SIGSTOP) to get a fixed list of
-                         ;; processes, like 'killall5' does, but that seems
-                         ;; unreliable.
-                         (kill-except omitted-pids SIGTERM)
-                         (sleep #$grace-delay)
-                         (kill-except omitted-pids SIGKILL)
-                         (delete-file #$%do-not-kill-file)))
+                   (kill -1 SIGTERM)
+                   (sleep #$grace-delay)
+                   (kill -1 SIGKILL)
 
                    (let wait ()
                      (let ((pids (processes)))
-                       (unless (lset= = pids (cons 1 omitted-pids))
+                       (unless (equal? '(1) pids)
                          (format #t "waiting for process termination\
  (processes left: ~s)~%"
                                  pids)
-- 
2.47.1





This bug report was last modified 100 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.