diff options
author | Marc G. Fournier | 1996-09-19 20:19:05 +0000 |
---|---|---|
committer | Marc G. Fournier | 1996-09-19 20:19:05 +0000 |
commit | 715c6b6d2543bed88d636a7b89277e55a85f437c (patch) | |
tree | e1ed20a1a2117b0c1e40bec57f4a3bcc726818e1 /contrib/pginterface/halt.c | |
parent | ee9b8016c70ac84cf56079a6879f9ebb5753e81f (diff) |
Newer version of Bruce's pginterface library...
Diffstat (limited to 'contrib/pginterface/halt.c')
-rw-r--r-- | contrib/pginterface/halt.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/contrib/pginterface/halt.c b/contrib/pginterface/halt.c new file mode 100644 index 00000000000..58ca11a5878 --- /dev/null +++ b/contrib/pginterface/halt.c @@ -0,0 +1,58 @@ +/* +** +** halt.c +** +** This is used to print out error messages and exit +*/ + +#include <varargs.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> + + +/*------------------------------------------------------------------------- +** +** halt - print error message, and call clean up routine or exit +** +**------------------------------------------------------------------------*/ + +/*VARARGS*/ +void halt(va_alist) +va_dcl +{ + va_list arg_ptr; + char *format, *pstr; + void (*sig_func)(); + + va_start(arg_ptr); + format = va_arg(arg_ptr,char *); + if (strncmp(format,"PERROR", 6) != 0) + vfprintf(stderr,format,arg_ptr); + else + { + for (pstr=format+6; *pstr == ' ' || *pstr == ':'; pstr++) + ; + vfprintf(stderr,pstr,arg_ptr); + perror(""); + } + va_end(arg_ptr); + fflush(stderr); + + /* call one clean up function if defined */ + if ( (sig_func = signal(SIGTERM, SIG_DFL)) != SIG_DFL && + sig_func != SIG_IGN) + (*sig_func)(0); + else if ( (sig_func = signal(SIGHUP, SIG_DFL)) != SIG_DFL && + sig_func != SIG_IGN) + (*sig_func)(0); + else if ( (sig_func = signal(SIGINT, SIG_DFL)) != SIG_DFL && + sig_func != SIG_IGN) + (*sig_func)(0); + else if ( (sig_func = signal(SIGQUIT, SIG_DFL)) != SIG_DFL && + sig_func != SIG_IGN) + (*sig_func)(0); + exit(1); +} |