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 54f5a88ea1
commit 74fcc8bff3
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))))