From d656c14ec9ed9ec68abeb68e98e9eaa602d9e11e Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 17 Sep 2014 09:13:51 +0200 Subject: services: user-processes: Wait for complete process termination. * gnu/services/base.scm (user-processes-service): Add 'wait' loop. --- gnu/services/base.scm | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gnu/services') diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 3b85363fe2..9bc78bd1ae 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -182,6 +182,8 @@ stopped before 'kill' is called." (@ (ice-9 rdelim) read-string)))) '())) + (define lset= (@ (srfi srfi-1) lset=)) + ;; When this happens, all the processes have been ;; killed, including 'deco', so DMD-OUTPUT-PORT and ;; thus CURRENT-OUTPUT-PORT are dangling. @@ -206,6 +208,15 @@ stopped before 'kill' is called." (kill-except omitted-pids SIGKILL) (delete-file #$%do-not-kill-file))) + (let wait () + (let ((pids (processes))) + (unless (lset= = pids (cons 1 omitted-pids)) + (format #t "waiting for process termination\ + (processes left: ~s)~%" + pids) + (sleep 2) + (wait)))) + (display "all processes have been terminated\n") #f)) (respawn? #f))))) -- cgit 1.4.1