diff options
author | Ludovic Courtès <ludo@gnu.org> | 2013-07-12 23:01:07 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2013-07-12 23:01:18 +0200 |
commit | e14c39291bb55ba336cb3fc2c44224154c8500c0 (patch) | |
tree | 759678de71c072128f8edc89cd2529250161f8d8 | |
parent | e3ccdf9e963c1ec00f8dcf8cc859ab4615b978c4 (diff) | |
download | patches-e14c39291bb55ba336cb3fc2c44224154c8500c0.tar patches-e14c39291bb55ba336cb3fc2c44224154c8500c0.tar.gz |
ui: Ignore SIGPIPE and catch `system-error' exceptions.
* guix/ui.scm (initialize-guix): Call `sigaction'.
(call-with-error-handling): Wrap `thunk' in a (catch 'system-error ...).
-rw-r--r-- | guix/ui.scm | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/guix/ui.scm b/guix/ui.scm index fd35c6a8c8..2ee8c02306 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -120,6 +120,11 @@ messages." "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 @@ General help using GNU software: <http://www.gnu.org/gethelp/>")) ;; 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 |