Manfred Spraul wrote:
> Bruce Momjian wrote:
>
> >>
> >>+ /*
> >>+ * We could lose a signal during this test.
> >>+ * In a multi-threaded application, this might
> >>+ * be a problem. Do any non-threaded platforms
> >>
> Threaded or non-threaded?
>
> >>+ * lack sigaction()?
> >>+ */
> >>
> Additionally, the problem is not restricted to multithreaded apps:
> signal(,SIG_IGN) clears all pending signals.
OK, new function using sigblock():
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 */
}
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073