Hey, In the mg(1) *compile* buffer, currently you get incorrect output like:
Command exited abnormally with code 256 at [...] Using the W* macros in <sys/wait.h> corrects this: Command exited abnormally with code 1 at [...] ok? -- Scott Cheloha Index: usr.bin/mg/grep.c =================================================================== RCS file: /cvs/src/usr.bin/mg/grep.c,v retrieving revision 1.45 diff -u -p -r1.45 grep.c --- usr.bin/mg/grep.c 12 Oct 2017 14:12:00 -0000 1.45 +++ usr.bin/mg/grep.c 2 Jan 2018 01:42:11 -0000 @@ -4,6 +4,8 @@ #include <sys/queue.h> #include <sys/types.h> +#include <sys/wait.h> + #include <ctype.h> #include <libgen.h> #include <limits.h> @@ -180,7 +182,7 @@ compile_mode(const char *name, const cha char *buf; size_t sz; ssize_t len; - int ret, n; + int ret, n, status; char cwd[NFILEN], qcmd[NFILEN]; char timestr[NTIME]; time_t t; @@ -223,12 +225,13 @@ compile_mode(const char *name, const cha if (ferror(fpipe)) ewprintf("Problem reading pipe"); ret = pclose(fpipe); + status = WIFEXITED(ret) ? WEXITSTATUS(ret) : 128 + WTERMSIG(ret); t = time(NULL); strftime(timestr, sizeof(timestr), "%a %b %e %T %Y", localtime(&t)); addline(bp, ""); - if (ret != 0) + if (status != 0) addlinef(bp, "Command exited abnormally with code %d" - " at %s", ret, timestr); + " at %s", status, timestr); else addlinef(bp, "Command finished at %s", timestr);