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 <janneke@gnu.org>

* mes/module/mes/posix.mes (status:exit-val): New function.
* module/mescc/mescc.scm (assert-system*): Use it.
This commit is contained in:
Peter De Wachter 2018-10-16 20:40:35 +02:00 committed by Jan Nieuwenhuizen
parent cc473c1d72
commit 053309e4dc
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
2 changed files with 4 additions and 1 deletions

View file

@ -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))

View file

@ -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))))