Commit f03b75e4 authored by Bruce Momjian's avatar Bruce Momjian

Removed un-needed signal suff from pginterface.

parent 604ce32e
...@@ -22,14 +22,6 @@ useful if you are running the query engine on a system with a different ...@@ -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 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. 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 There is a demo program called pginsert that demonstrates how the
library can be used. library can be used.
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <signal.h>
#include <time.h>
#include <libpq-fe.h> #include <libpq-fe.h>
#include "halt.h" #include "halt.h"
#include "pginterface.h" #include "pginterface.h"
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <signal.h>
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
...@@ -12,9 +11,6 @@ ...@@ -12,9 +11,6 @@
#include "halt.h" #include "halt.h"
#include "pginterface.h" #include "pginterface.h"
static void sig_disconnect();
static void set_signals();
#define NUL '\0' #define NUL '\0'
/* GLOBAL VARIABLES */ /* GLOBAL VARIABLES */
...@@ -27,8 +23,6 @@ static PGresult *res = NULL; ...@@ -27,8 +23,6 @@ static PGresult *res = NULL;
static int on_error_state = ON_ERROR_STOP; static int on_error_state = ON_ERROR_STOP;
/* LOCAL VARIABLES */ /* LOCAL VARIABLES */
static sigset_t block_sigs,
unblock_sigs;
static int tuple; static int tuple;
/* /*
...@@ -48,7 +42,6 @@ connectdb(char *dbName, ...@@ -48,7 +42,6 @@ connectdb(char *dbName,
if (PQstatus(conn) == CONNECTION_BAD) if (PQstatus(conn) == CONNECTION_BAD)
halt("Connection to database '%s' failed.\n%s\n", dbName, halt("Connection to database '%s' failed.\n%s\n", dbName,
PQerrorMessage(conn)); PQerrorMessage(conn));
set_signals();
return conn; return conn;
} }
...@@ -74,9 +67,7 @@ doquery(char *query) ...@@ -74,9 +67,7 @@ doquery(char *query)
if (res != NULL) if (res != NULL)
PQclear(res); PQclear(res);
sigprocmask(SIG_SETMASK, &block_sigs, NULL);
res = PQexec(conn, query); res = PQexec(conn, query);
sigprocmask(SIG_SETMASK, &unblock_sigs, NULL);
if (on_error_state == ON_ERROR_STOP && if (on_error_state == ON_ERROR_STOP &&
(res == NULL || (res == NULL ||
...@@ -196,37 +187,3 @@ on_error_continue() ...@@ -196,37 +187,3 @@ on_error_continue()
{ {
on_error_state = 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);
}
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
#define TEST_NON_NULLS #define TEST_NON_NULLS
#include <stdio.h> #include <stdio.h>
#include <signal.h>
#include <time.h>
#include <halt.h> #include <halt.h>
#include <libpq-fe.h> #include <libpq-fe.h>
#include <pginterface.h> #include <pginterface.h>
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <signal.h>
#include <time.h>
#include "halt.h" #include "halt.h"
#include <libpq-fe.h> #include <libpq-fe.h>
#include "pginterface.h" #include "pginterface.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment