* Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.12 1996/11/22 04:32:41 bryanh Exp $
+ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.13 1996/12/26 22:06:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "access/skey.h"
#include "access/strat.h"
#include "utils/rel.h"
+#include "libpq/pqsignal.h"
#include "storage/block.h"
#include "storage/off.h"
* initialize signal handlers
* ----------------
*/
- signal(SIGINT, (sig_func) die);
+ pqsignal(SIGINT, (sig_func) die);
#ifndef win32
- signal(SIGHUP, (sig_func) die);
- signal(SIGTERM, (sig_func) die);
+ pqsignal(SIGHUP, (sig_func) die);
+ pqsignal(SIGTERM, (sig_func) die);
#endif /* win32 */
/* --------------------
* ----------------
*/
#ifndef win32
- signal(SIGHUP, handle_warn);
+ pqsignal(SIGHUP, handle_warn);
if (sigsetjmp(Warn_restart, 1) != 0) {
#else
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.9 1996/11/24 04:05:20 bryanh Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.10 1996/12/26 22:07:03 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
#include <stdio.h>
#include <string.h>
+#include <signal.h>
#include <errno.h>
#include <fcntl.h>
#ifndef WIN32
#include <postgres.h>
-#include <libpq/pqsignal.h> /* substitute for <signal.h> */
+#include <libpq/pqsignal.h>
#include <libpq/auth.h>
#include <libpq/libpq.h> /* where the declarations go */
#else /* hpux */
fcntl(fd, F_SETOWN, getpid());
#endif /* hpux */
- (void) signal(SIGURG,fptr);
+ (void) pqsignal(SIGURG,fptr);
#endif /* WIN32 */
}
pq_unregoob()
{
#ifndef WIN32
- signal(SIGURG,SIG_DFL);
+ pqsignal(SIGURG,SIG_DFL);
#endif /* WIN32 */
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/libpq/pqsignal.c,v 1.4 1996/11/18 02:25:09 bryanh Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/pqsignal.c,v 1.5 1996/12/26 22:07:08 momjian Exp $
*
* NOTES
* This shouldn't be in libpq, but the monitor and some other
* ------------------------------------------------------------------------*/
#include <postgres.h>
+#include <signal.h>
+
#include <libpq/pqsignal.h>
pqsigfunc
pqsignal(int signo, pqsigfunc func)
{
-#if defined(USE_POSIX_SIGNALS)
+#if !defined(USE_POSIX_SIGNALS)
+ return signal(signo, func);
+#else
struct sigaction act, oact;
act.sa_handler = func;
if (sigaction(signo, &act, &oact) < 0)
return(SIG_ERR);
return(oact.sa_handler);
-#else /* !USE_POSIX_SIGNALS */
- Assert(0);
- return 0;
#endif /* !USE_POSIX_SIGNALS */
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.29 1996/12/26 17:49:05 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.30 1996/12/26 22:07:17 momjian Exp $
*
* NOTES
*
#include "postgres.h"
-#include "libpq/pqsignal.h" /* substitute for <signal.h> */
+#include <signal.h>
#include <string.h>
#include <stdlib.h>
#include "libpq/libpq.h"
#include "libpq/auth.h"
#include "libpq/pqcomm.h"
+#include "libpq/pqsignal.h"
#include "miscadmin.h"
#include "version.h"
#include "lib/dllist.h"
if (silentflag)
pmdaemonize();
- signal(SIGINT, pmdie);
+ pqsignal(SIGINT, pmdie);
#ifndef WIN32
- signal(SIGCHLD, reaper);
- signal(SIGTTIN, SIG_IGN);
- signal(SIGTTOU, SIG_IGN);
- signal(SIGHUP, pmdie);
- signal(SIGTERM, pmdie);
- signal(SIGCONT, dumpstatus);
+ pqsignal(SIGCHLD, reaper);
+ pqsignal(SIGTTIN, SIG_IGN);
+ pqsignal(SIGTTOU, SIG_IGN);
+ pqsignal(SIGHUP, pmdie);
+ pqsignal(SIGTERM, pmdie);
+ pqsignal(SIGCONT, dumpstatus);
#endif /* WIN32 */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.11 1996/11/27 07:17:48 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.12 1996/12/26 22:07:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* This is so that we can support more backends. (system-wide semaphore
* sets run out pretty fast.) -ay 4/95
*
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.11 1996/11/27 07:17:48 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.12 1996/12/26 22:07:28 momjian Exp $
*/
#include <sys/time.h>
#ifndef WIN32
#include "postgres.h"
#include "miscadmin.h"
-#include "libpq/pqsignal.h" /* substitute for <signal.h> */
+#include "libpq/pqsignal.h"
#include "access/xact.h"
#include "utils/hsearch.h"
* ------------------
*/
#ifndef WIN32
- signal(SIGALRM, HandleDeadLock);
+ pqsignal(SIGALRM, HandleDeadLock);
#endif /* WIN32 we'll have to figure out how to handle this later */
SpinAcquire(ProcStructLock);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.23 1996/12/07 04:39:06 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.24 1996/12/26 22:07:40 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
*
*-------------------------------------------------------------------------
*/
-#include "libpq/pqsignal.h" /* substitute for <signal.h> */
#include <unistd.h>
#include <stdio.h>
#include <string.h>
+#include <signal.h>
#include <time.h>
#include <setjmp.h>
#include <sys/time.h>
#include "tcop/fastpath.h"
#include "libpq/libpq.h"
+#include "libpq/pqsignal.h"
#include "rewrite/rewriteHandler.h" /* for QueryRewrite() */
/* ----------------
* register signal handlers.
* ----------------
*/
- signal(SIGINT, die);
+ pqsignal(SIGINT, die);
#ifndef WIN32
- signal(SIGHUP, die);
- signal(SIGTERM, die);
- signal(SIGPIPE, die);
- signal(SIGUSR1, quickdie);
- signal(SIGUSR2, Async_NotifyHandler);
- signal(SIGFPE, FloatExceptionHandler);
+ pqsignal(SIGHUP, die);
+ pqsignal(SIGTERM, die);
+ pqsignal(SIGPIPE, die);
+ pqsignal(SIGUSR1, quickdie);
+ pqsignal(SIGUSR2, Async_NotifyHandler);
+ pqsignal(SIGFPE, FloatExceptionHandler);
#endif /* WIN32 */
/* --------------------
*/
#ifndef WIN32
- signal(SIGHUP, handle_warn);
+ pqsignal(SIGHUP, handle_warn);
if (sigsetjmp(Warn_restart, 1) != 0) {
#else
*/
if (IsUnderPostmaster == false) {
puts("\nPOSTGRES backend interactive interface");
- puts("$Revision: 1.23 $ $Date: 1996/12/07 04:39:06 $");
+ puts("$Revision: 1.24 $ $Date: 1996/12/26 22:07:40 $");
}
/* ----------------
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.41 1996/12/26 20:56:40 bryanh Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.42 1996/12/26 22:07:57 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include <ctype.h>
#include "postgres.h"
#include "libpq-fe.h"
+#include "pqsignal.h"
#include "stringutils.h"
#include "psqlHelp.h"
#ifdef NEED_STRDUP
break;
case PGRES_COPY_IN:
*success_p = true;
- if (copy_in) {
+ if (copy_in)
handleCopyIn(results, false, copystream);
- } else {
- char c;
- /*
- * eat extra newline still in input buffer
- *
- */
- fflush(stdin);
- if ((c = getc(stdin)) != '\n' && c != EOF)
- (void) ungetc(c, stdin);
+ else
handleCopyIn(results, !settings->quiet, stdin);
- }
break;
case PGRES_NONFATAL_ERROR:
case PGRES_FATAL_ERROR:
else
fclose(ps->queryFout);
}
- if (!fname)
+ if (!fname) {
ps->queryFout = stdout;
+ pqsignal(SIGPIPE, SIG_DFL);
+ }
else {
if (*fname == '|') {
- signal(SIGPIPE, SIG_IGN);
+ pqsignal(SIGPIPE, SIG_IGN);
ps->queryFout = popen(fname + 1, "w");
ps->pipe = 1;
} else {
ps->queryFout = fopen(fname, "w");
+ pqsignal(SIGPIPE, SIG_DFL);
ps->pipe = 0;
}
if (!ps->queryFout) {
#if defined(dgux)
# define LINUX_ELF
# define NEED_UNION_SEMUN
-# define __USE_POSIX_SIGNALS
-# define -DUSE_POSIX_SIGNALS
+# define USE_POSIX_SIGNALS
#endif
#if defined(hpux)
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: pqsignal.h,v 1.4 1996/11/24 04:07:17 bryanh Exp $
+ * $Id: pqsignal.h,v 1.5 1996/12/26 22:08:13 momjian Exp $
*
* NOTES
* This shouldn't be in libpq, but the monitor and some other
#ifndef PQSIGNAL_H
#define PQSIGNAL_H
-#include <signal.h>
-
typedef void (*pqsigfunc)(int);
extern pqsigfunc pqsignal(int signo, pqsigfunc func);
-#if defined(USE_POSIX_SIGNALS)
-#define signal(signo, handler) pqsignal(signo, (pqsigfunc)(handler))
-#endif /* USE_POSIX_SIGNALS */
-
#endif /* PQSIGNAL_H */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.23 1996/12/24 09:03:16 bryanh Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.24 1996/12/26 22:08:21 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
+#include <signal.h>
#include <string.h>
#include <errno.h>
#include "postgres.h"
#include "libpq/pqcomm.h"
+#include "libpq/pqsignal.h"
#include "libpq-fe.h"
-#include <signal.h>
#include <sys/ioctl.h>
#include TERMIOS_H_LOCATION
+
#ifdef TIOCGWINSZ
struct winsize screen_size;
#else
fout = popen(pagerenv, "w");
if (fout) {
usePipe = 1;
- signal(SIGPIPE, SIG_IGN);
+ pqsignal(SIGPIPE, SIG_IGN);
} else
fout = stdout;
}
free(fieldNames);
if (usePipe) {
pclose(fout);
- signal(SIGPIPE, SIG_DFL);
+ pqsignal(SIGPIPE, SIG_DFL);
}
if (border)
free(border);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/pqsignal.c,v 1.2 1996/11/08 06:02:30 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/pqsignal.c,v 1.3 1996/12/26 22:08:30 momjian Exp $
*
* NOTES
* This shouldn't be in libpq, but the monitor and some other
*/
#include <stdlib.h>
+#include <signal.h>
+
#include "libpq/pqsignal.h"
pqsigfunc
pqsignal(int signo, pqsigfunc func)
{
-#if defined(USE_POSIX_SIGNALS)
+#if !defined(USE_POSIX_SIGNALS)
+ return signal(signo, func);
+#else
struct sigaction act, oact;
act.sa_handler = func;
if (sigaction(signo, &act, &oact) < 0)
return(SIG_ERR);
return(oact.sa_handler);
-#else /* !USE_POSIX_SIGNALS */
- exit(1); /* this should never be reached, pqsignal should only
- be called if USE_POSIX_SIGNALS is true*/
#endif /* !USE_POSIX_SIGNALS */
}
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: pqsignal.h,v 1.1.1.1 1996/07/09 06:22:17 scrappy Exp $
+ * $Id: pqsignal.h,v 1.2 1996/12/26 22:08:34 momjian Exp $
*
* NOTES
* This shouldn't be in libpq, but the monitor and some other
#ifndef PQSIGNAL_H
#define PQSIGNAL_H
-#include <signal.h>
-
#include "c.h"
typedef void (*pqsigfunc)(int);
extern pqsigfunc pqsignal(int signo, pqsigfunc func);
-#if defined(USE_POSIX_SIGNALS)
-#define signal(signo, handler) pqsignal(signo, (pqsigfunc)(handler))
-#endif /* USE_POSIX_SIGNALS */
-
#endif /* PQSIGNAL_H */