diff --git a/contrib/pginterface/README b/contrib/pginterface/README index c52b5d1190a19db53cb3c25201d6cc0accc5f0ab..42fd0a5dfe7e6839d400880880632ba0a34170dc 100644 --- a/contrib/pginterface/README +++ b/contrib/pginterface/README @@ -22,14 +22,6 @@ useful if you are running the query engine on a system with a different architecture than the database server. If you pass a NULL pointer, the column is skipped, and you can use libpq to handle it as you wish. -I have used sigprocmask() to block the reception of certain signals -while the program is executing SQL queries. This prevents a user -pressing Control-C from stopping all the back ends. It blocks SIGHUP, -SIGINT, and SIGTERM, but does not block SIGQUIT or obviously kill -9. -If your platform does not support sigprocmask(), you can remove those -function calls. ( Am I correct that abnormal termination can cause -shared memory resynchronization?) - There is a demo program called pginsert that demonstrates how the library can be used. diff --git a/contrib/pginterface/pginsert.c b/contrib/pginterface/pginsert.c index 82838c2f8ccdb08474e72d8767a7bf7e5821ce44..46e3c2743ba4f5fdaefa8fec38083a96d53e7471 100644 --- a/contrib/pginterface/pginsert.c +++ b/contrib/pginterface/pginsert.c @@ -4,8 +4,6 @@ */ #include <stdio.h> -#include <signal.h> -#include <time.h> #include <libpq-fe.h> #include "halt.h" #include "pginterface.h" diff --git a/contrib/pginterface/pginterface.c b/contrib/pginterface/pginterface.c index cdc419352aaaf8379ce47d47579ef856f9dae9d5..1335baa1928d8a40cba161e6c52c9f51212c30d6 100644 --- a/contrib/pginterface/pginterface.c +++ b/contrib/pginterface/pginterface.c @@ -4,7 +4,6 @@ */ #include <stdio.h> -#include <signal.h> #include <string.h> #include <stdarg.h> @@ -12,9 +11,6 @@ #include "halt.h" #include "pginterface.h" -static void sig_disconnect(); -static void set_signals(); - #define NUL '\0' /* GLOBAL VARIABLES */ @@ -27,8 +23,6 @@ static PGresult *res = NULL; static int on_error_state = ON_ERROR_STOP; /* LOCAL VARIABLES */ -static sigset_t block_sigs, - unblock_sigs; static int tuple; /* @@ -48,7 +42,6 @@ connectdb(char *dbName, if (PQstatus(conn) == CONNECTION_BAD) halt("Connection to database '%s' failed.\n%s\n", dbName, PQerrorMessage(conn)); - set_signals(); return conn; } @@ -74,9 +67,7 @@ doquery(char *query) if (res != NULL) PQclear(res); - sigprocmask(SIG_SETMASK, &block_sigs, NULL); res = PQexec(conn, query); - sigprocmask(SIG_SETMASK, &unblock_sigs, NULL); if (on_error_state == ON_ERROR_STOP && (res == NULL || @@ -196,37 +187,3 @@ on_error_continue() { on_error_state = ON_ERROR_CONTINUE; } - -/* -** -** sig_disconnect -** -*/ -static void -sig_disconnect() -{ - fprintf(stderr, "exiting...\n"); - PQfinish(conn); - exit(1); -} - -/* -** -** set_signals -** -*/ -static void -set_signals() -{ - sigemptyset(&block_sigs); - sigemptyset(&unblock_sigs); - sigaddset(&block_sigs, SIGTERM); - sigaddset(&block_sigs, SIGHUP); - sigaddset(&block_sigs, SIGINT); -/* sigaddset(&block_sigs,SIGQUIT); no block */ - sigprocmask(SIG_SETMASK, &unblock_sigs, NULL); - signal(SIGTERM, sig_disconnect); - signal(SIGHUP, sig_disconnect); - signal(SIGINT, sig_disconnect); - signal(SIGQUIT, sig_disconnect); -} diff --git a/contrib/pginterface/pgnulltest.c b/contrib/pginterface/pgnulltest.c index 96873ca7c814dc739c19d43f4e3ac65e9820e0ff..69a1d44e854b795aa0001b146edf6025d054338c 100644 --- a/contrib/pginterface/pgnulltest.c +++ b/contrib/pginterface/pgnulltest.c @@ -6,8 +6,6 @@ #define TEST_NON_NULLS #include <stdio.h> -#include <signal.h> -#include <time.h> #include <halt.h> #include <libpq-fe.h> #include <pginterface.h> diff --git a/contrib/pginterface/pgwordcount.c b/contrib/pginterface/pgwordcount.c index 859cf90b2ad1e27c9aeb20627fae976ef5ea6d0c..4fe23187f026735954466db6830847d3d78e879c 100644 --- a/contrib/pginterface/pgwordcount.c +++ b/contrib/pginterface/pgwordcount.c @@ -4,8 +4,6 @@ */ #include <stdio.h> -#include <signal.h> -#include <time.h> #include "halt.h" #include <libpq-fe.h> #include "pginterface.h"