summaryrefslogtreecommitdiff
path: root/gnu/services/shepherd.scm
diff options
context:
space:
mode:
authorLudovic Courtès <[email protected]>2025-01-25 12:38:00 +0100
committerLudovic Courtès <[email protected]>2025-02-09 18:20:42 +0100
commitba9af3e151db8f0f86aeaea681a937e995b5b265 (patch)
treed7ddc3234215420ddc8671348024d475c9b5603b /gnu/services/shepherd.scm
parentb4b14a49cd2438d58f99787f768523bff080cdfd (diff)
services: user-processes: Simplify and streamline ‘stop’ action.
* gnu/services/shepherd.scm (user-processes-shepherd-service): In ‘stop’ action, remove ‘sleep*’, which is unnecessary when using Fibers, and remove the ‘reap-children’ loop and its ‘waitpid’ call, which is redundant with ‘waitpid’ calls made by shepherd itself and could cause confusion. Change-Id: I0df1733f0cbe781a0ad5fef4830d903483e0da27
Diffstat (limited to 'gnu/services/shepherd.scm')
-rw-r--r--gnu/services/shepherd.scm31
1 files changed, 3 insertions, 28 deletions
diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm
index 328bfbedff..d222628280 100644
--- a/gnu/services/shepherd.scm
+++ b/gnu/services/shepherd.scm
@@ -594,18 +594,6 @@ system mounts, etc. This is similar to the 'sysvinit' target in systemd."
(@ (ice-9 rdelim) read-string))))
'()))
- (define (now)
- (car (gettimeofday)))
-
- (define (sleep* n)
- ;; Really sleep N seconds.
- ;; Work around <http://bugs.gnu.org/19581>.
- (define start (now))
- (let loop ((elapsed 0))
- (when (> n elapsed)
- (sleep (- n elapsed))
- (loop (- (now) start)))))
-
(define lset= (@ (srfi srfi-1) lset=))
(display "sending all processes the TERM signal\n")
@@ -614,7 +602,7 @@ system mounts, etc. This is similar to the 'sysvinit' target in systemd."
(begin
;; Easy: terminate all of them.
(kill -1 SIGTERM)
- (sleep* #$grace-delay)
+ (sleep #$grace-delay)
(kill -1 SIGKILL))
(begin
;; Kill them all except OMITTED-PIDS. XXX: We would
@@ -622,30 +610,17 @@ system mounts, etc. This is similar to the 'sysvinit' target in systemd."
;; processes, like 'killall5' does, but that seems
;; unreliable.
(kill-except omitted-pids SIGTERM)
- (sleep* #$grace-delay)
+ (sleep #$grace-delay)
(kill-except omitted-pids SIGKILL)
(delete-file #$%do-not-kill-file)))
(let wait ()
- ;; Reap children, if any, so that we don't end up with
- ;; zombies and enter an infinite loop.
- (let reap-children ()
- (define result
- (false-if-exception
- (waitpid WAIT_ANY (if (null? omitted-pids)
- 0
- WNOHANG))))
-
- (when (and (pair? result)
- (not (zero? (car result))))
- (reap-children)))
-
(let ((pids (processes)))
(unless (lset= = pids (cons 1 omitted-pids))
(format #t "waiting for process termination\
(processes left: ~s)~%"
pids)
- (sleep* 2)
+ (sleep 1)
(wait))))
(display "all processes have been terminated\n")