summaryrefslogtreecommitdiff
path: root/guix/scripts/environment.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-11-21 22:24:45 +0100
committerLudovic Courtès <ludo@gnu.org>2015-11-21 22:26:13 +0100
commit82e64fc14eec9f01f5fee12782046496ebed9c72 (patch)
treec4d8dff78313e4102be683137d9c1a03450f6338 /guix/scripts/environment.scm
parent6493fd04581a923d42a566a869b3490d3a159db7 (diff)
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.
Diffstat (limited to 'guix/scripts/environment.scm')
-rw-r--r--guix/scripts/environment.scm11
1 files changed, 9 insertions, 2 deletions
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index 97410f4e09..fae261733e 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