From 053309e4dca4b04f1ad1b2c54c4972c4985012b5 Mon Sep 17 00:00:00 2001 From: Peter De Wachter Date: Tue, 16 Oct 2018 20:40:35 +0200 Subject: [PATCH] mescc: Exit with non-zero exit code when subprocess fails. system* returns the result of waitpid. So, suppose that a subprocess fails with exit code 1. Then the waitpid return value will be 256. And exit(256) is equivalent to exit(0). Modified-by: Jan Nieuwenhuizen * mes/module/mes/posix.mes (status:exit-val): New function. * module/mescc/mescc.scm (assert-system*): Use it. --- mes/module/mes/posix.mes | 3 +++ module/mescc/mescc.scm | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/mes/module/mes/posix.mes b/mes/module/mes/posix.mes index ae6288f7..3f081d5b 100644 --- a/mes/module/mes/posix.mes +++ b/mes/module/mes/posix.mes @@ -57,3 +57,6 @@ (define (waitpid pid . options) (let ((options (if (null? options) 0 (car options)))) (core:waitpid pid options))) + +(define (status:exit-val status) + (ash status -8)) diff --git a/module/mescc/mescc.scm b/module/mescc/mescc.scm index be06d943..e3d93a1e 100644 --- a/module/mescc/mescc.scm +++ b/module/mescc/mescc.scm @@ -281,7 +281,7 @@ (let ((status (apply system* args))) (when (not (zero? status)) (stderr "mescc: failed: ~a\n" (string-join args)) - (exit status)) + (exit (status:exit-val status))) status)) (define (multi-opt option-name) (lambda (o) (and (eq? (car o) option-name) (cdr o))))