diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm index be5ad78b9..2c6cb4ad2 100644 --- a/guix/build/gnu-build-system.scm +++ b/guix/build/gnu-build-system.scm @@ -51,6 +51,28 @@ (define time-monotonic time-tai)) (else #t)) +(define* (install-SIGCHLD-handler #:rest _) + "Handle SIGCHLD signals. Since this code is usually running as PID 1 in the +build daemon, it has to reap dead processes, hence this procedure." + ;; In Guile <= 2.0.9, syscalls could throw EINTR. With these versions, + ;; installing a SIGCHLD handler is not safe because we could have uncaught + ;; 'system-error' exceptions at any time. + (when (or (not (string=? (effective-version) "2.0")) + (> (string->number (micro-version)) 9)) + (format #t "installing SIGCHLD handler in PID ~a\n" (getpid)) + (sigaction SIGCHLD + (lambda _ + (let loop () + (match (catch 'system-error + (lambda () + (waitpid WAIT_ANY WNOHANG)) + (lambda args + '(0 . -))) + ((0 . _) #f) + ((pid . _) (loop))))) + SA_NOCLDSTOP)) + #t) + (define* (set-SOURCE-DATE-EPOCH #:rest _) "Set the 'SOURCE_DATE_EPOCH' environment variable. This is used by tools that incorporate timestamps as a way to tell them to use a fixed timestamp. @@ -758,7 +780,8 @@ which cannot be found~%" ;; Standard build phases, as a list of symbol/procedure pairs. (let-syntax ((phases (syntax-rules () ((_ p ...) `((p . ,p) ...))))) - (phases set-SOURCE-DATE-EPOCH set-paths install-locale unpack + (phases install-SIGCHLD-handler + set-SOURCE-DATE-EPOCH set-paths install-locale unpack bootstrap patch-usr-bin-file patch-source-shebangs configure patch-generated-file-shebangs