From ba826bad5caf1d699ed5939461fa9774dcc84df9 Mon Sep 17 00:00:00 2001 From: duk Date: Thu, 10 Jan 1985 13:17:22 +0000 Subject: [PATCH] Added routine to check signals. --- util/led/error.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 util/led/error.c diff --git a/util/led/error.c b/util/led/error.c new file mode 100644 index 000000000..59c011e27 --- /dev/null +++ b/util/led/error.c @@ -0,0 +1,71 @@ +#ifndef lint +static char rcsid[] = "$Header$"; +#endif + +#include +#include +#include "out.h" +#include "const.h" + +static short nerrors = 0; + +static +stop() +{ + extern char *outputname; + + if (nerrors) + unlink(outputname); + + exit(nerrors); +} + +trap_signals() +{ + static int trap_them[] = { SIGHUP, SIGINT, SIGQUIT, SIGTERM, 0 }; + register int *ip; + + for (ip = trap_them; *ip; ip++) + if (signal(*ip, stop) == SIG_IGN) + signal(*ip, SIG_IGN); /* Oops, reset. */ +} + +/* VARARGS1 */ +fatal(format, a1, a2, a3, a4) + char *format; +{ + nerrors++; + diag("fatal", format, a1, a2, a3, a4); + stop(); +} + +/* VARARGS1 */ +warning(format, a1, a2, a3, a4) + char *format; +{ + diag("warning", format, a1, a2, a3, a4); +} + +/* VARARGS1 */ +error(format, a1, a2, a3, a4) + char *format; +{ + nerrors++; + diag("error", format, a1, a2, a3, a4); +} + +static +diag(tail, format, a1, a2, a3, a4) + char *tail; + char *format; +{ + extern char *progname, *archname, *modulname; + + fprintf(stderr, "%s: ", progname); + if (archname) + fprintf(stderr, "%s: ", archname); + if (modulname) + fprintf(stderr, "%s: ", modulname); + fprintf(stderr, format, a1, a2, a3, a4); + fprintf(stderr, " (%s)\n", tail); +} -- 2.34.1