mirror of
https://github.com/postgres/postgres.git
synced 2025-11-19 13:42:17 +03:00
pq/signal() portability patch. Also psql copy prompt fix.
This commit is contained in:
@@ -7,22 +7,24 @@
|
||||
*
|
||||
*
|
||||
* 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
|
||||
@@ -1125,7 +1127,7 @@ PQprint(FILE *fout,
|
||||
fout = popen(pagerenv, "w");
|
||||
if (fout) {
|
||||
usePipe = 1;
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
pqsignal(SIGPIPE, SIG_IGN);
|
||||
} else
|
||||
fout = stdout;
|
||||
}
|
||||
@@ -1217,7 +1219,7 @@ PQprint(FILE *fout,
|
||||
free(fieldNames);
|
||||
if (usePipe) {
|
||||
pclose(fout);
|
||||
signal(SIGPIPE, SIG_DFL);
|
||||
pqsignal(SIGPIPE, SIG_DFL);
|
||||
}
|
||||
if (border)
|
||||
free(border);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* 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
|
||||
@@ -18,12 +18,16 @@
|
||||
*/
|
||||
#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;
|
||||
@@ -35,8 +39,5 @@ pqsignal(int signo, pqsigfunc 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 */
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* 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
|
||||
@@ -17,16 +17,10 @@
|
||||
#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 */
|
||||
|
||||
Reference in New Issue
Block a user