diff options
Diffstat (limited to 'guix/shepherd-with-sock.scm')
-rw-r--r-- | guix/shepherd-with-sock.scm | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/guix/shepherd-with-sock.scm b/guix/shepherd-with-sock.scm index 2667b8c..cd4138d 100644 --- a/guix/shepherd-with-sock.scm +++ b/guix/shepherd-with-sock.scm @@ -1,4 +1,7 @@ (define-module (shepherd-with-sock) + #:use-module ((shepherd service) + #:select (handle-SIGCHLD + catch-system-error)) #:export (make-forkexec-constructor)) @@ -126,6 +129,10 @@ false." program (strerror (system-error-errno args))) (primitive-exit 1))))) +(define (ensure-sigchld-handler) + (unless (@@ (shepherd service) %sigchld-handler-installed?) + (sigaction SIGCHLD handle-SIGCHLD SA_NOCLDSTOP) + (set! (@@ (shepherd service) %sigchld-handler-installed?) #t))) (define* (fork+exec-command command #:key @@ -138,10 +145,8 @@ false." (stdin-socket #f)) "Spawn a process that executed COMMAND as per 'exec-command', and return its PID." + (ensure-sigchld-handler) ;; Install the SIGCHLD handler if this is the first fork+exec-command call - (unless %sigchld-handler-installed? - (sigaction SIGCHLD handle-SIGCHLD SA_NOCLDSTOP) - (set! %sigchld-handler-installed? #t)) (let ((pid (primitive-fork))) (if (zero? pid) (exec-command command |