From b624ad8b342ac9a1454765d0e0c4f99c34b57e30 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Wed, 16 Sep 2020 20:09:45 +0100 Subject: Extract call-with-sigint to the utils module --- guix-build-coordinator/utils.scm | 20 +++++++++++++++++++- scripts/guix-build-coordinator.in | 15 --------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/guix-build-coordinator/utils.scm b/guix-build-coordinator/utils.scm index 440b31b..d2b5a6d 100644 --- a/guix-build-coordinator/utils.scm +++ b/guix-build-coordinator/utils.scm @@ -24,6 +24,7 @@ #:use-module (gcrypt random) #:use-module (fibers) #:use-module (fibers channels) + #:use-module (fibers conditions) #:use-module (json) #:use-module (guix pki) #:use-module (guix utils) @@ -56,7 +57,9 @@ create-work-queue - with-timeout)) + with-timeout + + call-with-sigint)) (define %worker-thread-args @@ -634,3 +637,18 @@ again." (alarm 0) (sigaction SIGALRM SIG_DFL) (apply values result))))) + +;; Copied from (fibers web server) +(define (call-with-sigint thunk cvar) + (let ((handler #f)) + (dynamic-wind + (lambda () + (set! handler + (sigaction SIGINT (lambda (sig) (signal-condition! cvar))))) + thunk + (lambda () + (if handler + ;; restore Scheme handler, SIG_IGN or SIG_DFL. + (sigaction SIGINT (car handler) (cdr handler)) + ;; restore original C handler. + (sigaction SIGINT #f)))))) diff --git a/scripts/guix-build-coordinator.in b/scripts/guix-build-coordinator.in index 7ea92a7..da22c1f 100644 --- a/scripts/guix-build-coordinator.in +++ b/scripts/guix-build-coordinator.in @@ -467,21 +467,6 @@ processed?: ~A (parameterize ((%show-error-details (assoc-ref opts 'show-error-details))) - ;; Copied from (fibers web server) - (define (call-with-sigint thunk cvar) - (let ((handler #f)) - (dynamic-wind - (lambda () - (set! handler - (sigaction SIGINT (lambda (sig) (signal-condition! cvar))))) - thunk - (lambda () - (if handler - ;; restore Scheme handler, SIG_IGN or SIG_DFL. - (sigaction SIGINT (car handler) (cdr handler)) - ;; restore original C handler. - (sigaction SIGINT #f)))))) - (let* ((agent-communication-thunk (let ((agent-communication-uri (string->uri (assq-ref opts 'agent-communication)))) -- cgit v1.2.3