aboutsummaryrefslogtreecommitdiff
path: root/src/extend/pginsert/halt.c
diff options
context:
space:
mode:
authorMarc G. Fournier <scrappy@hub.org>1996-07-23 03:13:58 +0000
committerMarc G. Fournier <scrappy@hub.org>1996-07-23 03:13:58 +0000
commit668aa24fc495a142fdf2ac12b32d849a04b21dc0 (patch)
treef281c2ddfcf5cc9936c38ac9a8c4aef022e41fab /src/extend/pginsert/halt.c
parent772ae267e36f15136d900f560517835ac833840a (diff)
downloadpostgresql-668aa24fc495a142fdf2ac12b32d849a04b21dc0.tar.gz
postgresql-668aa24fc495a142fdf2ac12b32d849a04b21dc0.zip
More merge's from Dr. George's sourec tree
Diffstat (limited to 'src/extend/pginsert/halt.c')
-rw-r--r--src/extend/pginsert/halt.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/extend/pginsert/halt.c b/src/extend/pginsert/halt.c
new file mode 100644
index 00000000000..58ca11a5878
--- /dev/null
+++ b/src/extend/pginsert/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);
+}