Fix obsolete comment regarding FSM truncation.
[PostgreSQL.git] / src / tools / entab / halt.c
blobbed8e453586ddbab0772843458b14c72ef8ddfe4
1 /*
2 **
3 ** halt.c
4 **
5 ** $PostgreSQL$
6 **
7 ** This is used to print out error messages and exit
8 */
10 #include <stdarg.h>
11 #include <signal.h>
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <errno.h>
17 /*-------------------------------------------------------------------------
19 ** halt - print error message, and call clean up routine or exit
21 **------------------------------------------------------------------------*/
23 /*VARARGS*/
24 void
25 halt(const char *format,...)
27 va_list arg_ptr;
28 const char *pstr;
29 void (*sig_func) ();
31 va_start(arg_ptr, format);
32 if (strncmp(format, "PERROR", 6) != 0)
33 vfprintf(stderr, format, arg_ptr);
34 else
36 for (pstr = format + 6; *pstr == ' ' || *pstr == ':'; pstr++)
38 vfprintf(stderr, pstr, arg_ptr);
39 perror("");
41 va_end(arg_ptr);
42 fflush(stderr);
44 /* call one clean up function if defined */
45 if ((sig_func = signal(SIGTERM, SIG_DFL)) != SIG_DFL &&
46 sig_func != SIG_IGN)
47 (*sig_func) (0);
48 else if ((sig_func = signal(SIGHUP, SIG_DFL)) != SIG_DFL &&
49 sig_func != SIG_IGN)
50 (*sig_func) (0);
51 else if ((sig_func = signal(SIGINT, SIG_DFL)) != SIG_DFL &&
52 sig_func != SIG_IGN)
53 (*sig_func) (0);
54 else if ((sig_func = signal(SIGQUIT, SIG_DFL)) != SIG_DFL &&
55 sig_func != SIG_IGN)
56 (*sig_func) (0);
57 exit(1);