From: Ralph Corderoy Date: Sun, 27 Aug 2017 09:16:11 +0000 (+0100) Subject: Add MAX_EXIT, value 120, to limit some more exit(3) values. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/83e9f61111251e7841e2bb35a3591e123ca0a8bb Add MAX_EXIT, value 120, to limit some more exit(3) values. mhparam(1) altered to use new macro. ap(1) and dp(1) now limit. --- diff --git a/h/mh.h b/h/mh.h index bebe8b86..75812a3c 100644 --- a/h/mh.h +++ b/h/mh.h @@ -16,6 +16,13 @@ #define DMAXFOLDER 4 /* typical number of digits */ #define MAXFOLDER 1000 /* message increment */ +/* non-zero exit(3) values indicating the number of errors need to be + * capped else they interfere with the shell's use of high seven-bit + * values, and the shell's mapping of signals onto top-bit-set values. + * Plus, every so often the eight-bit value will wrap to zero, wrongly + * indicating success. */ +#define MAX_EXIT 120 + /* * This macro is for use by scan, for example, so that platforms with * a small BUFSIZ can easily allocate larger buffers. diff --git a/uip/ap.c b/uip/ap.c index ea93fd6f..a44ecf55 100644 --- a/uip/ap.c +++ b/uip/ap.c @@ -127,7 +127,7 @@ main (int argc, char **argv) status += process (addrs[addrp], width); fmt_free (fmt, 1); - done (status); + done(min(status, MAX_EXIT)); return 1; } diff --git a/uip/dp.c b/uip/dp.c index 56a0ae1c..ece04a3f 100644 --- a/uip/dp.c +++ b/uip/dp.c @@ -123,7 +123,7 @@ main (int argc, char **argv) context_save (); /* save the context file */ fmt_free (fmt, 1); - done (status); + done(min(status, MAX_EXIT)); return 1; } diff --git a/uip/mhparam.c b/uip/mhparam.c index 17705bc8..4aadec5d 100644 --- a/uip/mhparam.c +++ b/uip/mhparam.c @@ -253,7 +253,7 @@ main(int argc, char **argv) printf("%s: ", comps[i]); puts(value); - } else if (missed < 120) + } else if (missed < MAX_EXIT) missed++; } }