1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* pqsignal.c
|
1997-09-07 07:04:48 +02:00
|
|
|
* reliable BSD-style signal(2) routine stolen from RWW who stole it
|
|
|
|
* from Stevens...
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2000-06-11 13:40:09 +02:00
|
|
|
* $Header: /cvsroot/pgsql/src/interfaces/libpq/pqsignal.c,v 1.12 2000/06/11 11:40:07 petere Exp $
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
* NOTES
|
1997-09-07 07:04:48 +02:00
|
|
|
* This shouldn't be in libpq, but the monitor and some other
|
|
|
|
* things need it...
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1996-11-08 07:02:30 +01:00
|
|
|
#include <stdlib.h>
|
1996-12-26 23:08:34 +01:00
|
|
|
#include <signal.h>
|
|
|
|
|
1998-08-17 05:50:43 +02:00
|
|
|
#include "pqsignal.h"
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
pqsigfunc
|
|
|
|
pqsignal(int signo, pqsigfunc func)
|
|
|
|
{
|
2000-06-11 13:40:09 +02:00
|
|
|
#if !defined(HAVE_POSIX_SIGNALS)
|
1997-09-07 07:04:48 +02:00
|
|
|
return signal(signo, func);
|
1996-12-26 23:08:34 +01:00
|
|
|
#else
|
1997-09-07 07:04:48 +02:00
|
|
|
struct sigaction act,
|
1997-09-08 04:41:22 +02:00
|
|
|
oact;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
act.sa_handler = func;
|
|
|
|
sigemptyset(&act.sa_mask);
|
|
|
|
act.sa_flags = 0;
|
|
|
|
if (signo != SIGALRM)
|
|
|
|
act.sa_flags |= SA_RESTART;
|
|
|
|
if (sigaction(signo, &act, &oact) < 0)
|
1998-09-01 05:29:17 +02:00
|
|
|
return SIG_ERR;
|
|
|
|
return oact.sa_handler;
|
2000-06-11 13:40:09 +02:00
|
|
|
#endif /* !HAVE_POSIX_SIGNALS */
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|