guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03/03: environment: Correctly handle abnormal exits.


From: Ludovic Courtès
Subject: 03/03: environment: Correctly handle abnormal exits.
Date: Sat, 21 Nov 2015 21:26:21 +0000

civodul pushed a commit to branch master
in repository guix.

commit 82e64fc14eec9f01f5fee12782046496ebed9c72
Author: Ludovic Courtès <address@hidden>
Date:   Sat Nov 21 22:24:45 2015 +0100

    environment: Correctly handle abnormal exits.
    
    Fixes <http://bugs.gnu.org/21958>.
    
    * guix/scripts/environment.scm (status->exit-code): New procedure.
    (exit/status, primitive-exit/status): Use it.
    * tests/guix-environment-container.sh: Add test.
---
 guix/scripts/environment.scm        |   11 +++++++++--
 tests/guix-environment-container.sh |    7 +++++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index 97410f4..fae2617 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -317,8 +317,15 @@ requisite store items i.e. the union closure of all the 
inputs."
                                       (map input->requisites inputs))))
     (return (delete-duplicates (concatenate reqs)))))
 
-(define exit/status (compose exit status:exit-val))
-(define primitive-exit/status (compose primitive-exit status:exit-val))
+(define (status->exit-code status)
+  "Compute the exit code made from STATUS, a value as returned by 'waitpid',
+and suitable for 'exit'."
+  ;; See <bits/waitstatus.h>.
+  (or (status:exit-val status)
+      (logior #x80 (status:term-sig status))))
+
+(define exit/status (compose exit status->exit-code))
+(define primitive-exit/status (compose primitive-exit status->exit-code))
 
 (define (launch-environment command inputs paths pure?)
   "Run COMMAND in a new environment containing INPUTS, using the native search
diff --git a/tests/guix-environment-container.sh 
b/tests/guix-environment-container.sh
index 5670d01..703ab31 100644
--- a/tests/guix-environment-container.sh
+++ b/tests/guix-environment-container.sh
@@ -81,3 +81,10 @@ grep $(guix build guile-bootstrap) $tmpdir/mounts
 grep -e "$NIX_STORE_DIR/.*-bash" $tmpdir/mounts # bootstrap bash
 
 rm $tmpdir/mounts
+
+if guix environment --bootstrap --container \
+       --ad-hoc bootstrap-binaries -- kill -SEGV 2
+then false;
+else
+    test $? -gt 127
+fi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]