From c57b2fe19865afc21fd1fd9a7cad3286b05a9b22 Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Mon, 26 Mar 2018 22:08:26 +1100 Subject: [PATCH] guix: Reap finished child processes in build containers. * guix/derivations (build-expression->derivation)[prologue]: Handle SIGCHLD and reap child processes when they finish. --- guix/derivations.scm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/guix/derivations.scm b/guix/derivations.scm index da686e89e..27ab3e420 100644 --- a/guix/derivations.scm +++ b/guix/derivations.scm @@ -1201,6 +1201,21 @@ ALLOWED-REFERENCES, DISALLOWED-REFERENCES, LOCAL-BUILD?, and SUBSTITUTABLE?." (else drv)))))) inputs)) + ;; The root process in the build container should reap + ;; processes that die, so handle SIGCHLD. + (use-modules (ice-9 match)) + (sigaction SIGCHLD + (lambda _ + (let loop () + (match (catch 'system-error + (lambda () + (waitpid WAIT_ANY WNOHANG)) + (lambda args + '(0 . -))) + ((0 . _) #f) + ((pid . _) (loop))))) + SA_NOCLDSTOP) + ,@(if (null? modules) '() ;; Remove our own settings. -- 2.16.2