From a4b42825a198eb77baefea41b58a17f6504a729c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Tue, 8 Apr 2014 10:04:13 +0200
Subject: [PATCH] offload: Bail out when failing to register a GC root on the
 build machine.

* guix/scripts/offload.scm (register-gc-root): Call 'leave' when
  'close-pipe' returns non-zero.
---
 guix/scripts/offload.scm | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/guix/scripts/offload.scm b/guix/scripts/offload.scm
index 1d86f99ca84..0761d684925 100644
--- a/guix/scripts/offload.scm
+++ b/guix/scripts/offload.scm
@@ -317,7 +317,12 @@ (define script
   (let ((pipe (remote-pipe machine OPEN_READ
                            `("guile" "-c" ,(object->string script)))))
     (get-string-all pipe)
-    (close-pipe pipe)))
+    (let ((status (close-pipe pipe)))
+      (unless (zero? status)
+        ;; Better be safe than sorry: if we ignore the error here, then FILE
+        ;; may be GC'd just before we start using it.
+        (leave (_ "failed to register GC root for '~a' on '~a' (status: ~a)~%")
+               file machine status)))))
 
 (define (remove-gc-root machine)
   "Remove from MACHINE the GC root previously installed with
-- 
GitLab