diff --git a/guix/ui.scm b/guix/ui.scm index fd35c6a8c87224e05fa51168fbafd3d499e2538b..2ee8c0230613461e44442c884140cec5ec646980 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -120,6 +120,11 @@ (define (initialize-guix) "Perform the usual initialization for stand-alone Guix commands." (install-locale) (textdomain "guix") + + ;; Ignore SIGPIPE. If the daemon closes the connection, we prefer to be + ;; notified via an EPIPE later. + (sigaction SIGPIPE SIG_IGN) + (setvbuf (current-output-port) _IOLBF) (setvbuf (current-error-port) _IOLBF)) @@ -171,7 +176,12 @@ (define (call-with-error-handling thunk) ;; FIXME: Server-provided error messages aren't i18n'd. (leave (_ "build failed: ~a~%") (nix-protocol-error-message c)))) - (thunk))) + ;; Catch EPIPE and the likes. + (catch 'system-error + thunk + (lambda args + (leave (_ "~a~%") + (strerror (system-error-errno args))))))) (define (read/eval-package-expression str) "Read and evaluate STR and return the package it refers to, or exit an