From 7f090203d5fb033eb1b64778b03afad5bb35f5f2 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 28 Aug 2017 09:54:03 +0200 Subject: services: user-processes: Reap child processes. Fixes . Reported by Leo Famulari . * gnu/services/base.scm (user-processes-service-type)[stop]: Add 'reap-children' loop. * gnu/tests/base.scm (run-halt-test): New procedure. (%test-halt): New variable. --- gnu/services/base.scm | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'gnu/services') diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 54bd9ca2fb..5001298ab3 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -456,6 +456,19 @@ in KNOWN-MOUNT-POINTS when it is stopped." (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\ -- cgit v1.2.3