From cf897cbacc3ddcf5d5d553ee19002995985fff11 Mon Sep 17 00:00:00 2001
From: David Thompson <dthompson2@worcester.edu>
Date: Sat, 5 Sep 2015 13:36:53 -0400
Subject: [PATCH] build: syscalls: Properly handle clone errors.

* guix/build/syscalls.scm (clone): Catch -1 return value and throw error.
---
 guix/build/syscalls.scm | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index fc801a5e9de..093eb0a1a0e 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -325,7 +325,13 @@ (define clone
       "Create a new child process by duplicating the current parent process.
 Unlike the fork system call, clone accepts FLAGS that specify which resources
 are shared between the parent and child processes."
-      (proc syscall-id flags %null-pointer))))
+      (let ((ret (proc syscall-id flags %null-pointer))
+            (err (errno)))
+        (if (= ret -1)
+            (throw 'system-error "clone" "~d: ~A"
+                   (list flags (strerror err))
+                   (list err))
+            ret)))))
 
 (define setns
   ;; Some systems may be using an old (pre-2.14) version of glibc where there
-- 
GitLab