mirror of
https://github.com/postgres/postgres.git
synced 2025-11-21 00:42:43 +03:00
Allow libpq to do thread-safe SIGPIPE handling. This allows it to
ignore SIGPIPE from send() in libpq, but terminate on any other SIGPIPE, unless the user installs their own signal handler. This is a minor fix because the only time you get SIGPIPE from libpq's send() is when the backend dies.
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/pqsignal.c,v 1.18 2003/11/29 19:52:12 pgsql Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/pqsignal.c,v 1.19 2004/01/09 02:02:43 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* This shouldn't be in libpq, but the monitor and some other
|
||||
@@ -40,3 +40,25 @@ pqsignal(int signo, pqsigfunc func)
|
||||
return oact.sa_handler;
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
}
|
||||
|
||||
pqsigfunc
|
||||
pqsignalinquire(int signo)
|
||||
{
|
||||
#if !defined(HAVE_POSIX_SIGNALS)
|
||||
pqsigfunc old_sigfunc;
|
||||
int old_sigmask;
|
||||
|
||||
/* Prevent signal handler calls during test */
|
||||
old_sigmask = sigblock(sigmask(signo));
|
||||
old_sigfunc = signal(signo, SIG_DFL);
|
||||
signal(signo, old_sigfunc);
|
||||
sigblock(old_sigmask);
|
||||
return old_sigfunc;
|
||||
#else
|
||||
struct sigaction oact;
|
||||
|
||||
if (sigaction(signo, NULL, &oact) < 0)
|
||||
return SIG_ERR;
|
||||
return oact.sa_handler;
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user