Re: SIGPIPE handling - Mailing list pgsql-patches

From Bruce Momjian
Subject Re: SIGPIPE handling
Date
Msg-id 200401072308.i07N80v22744@candle.pha.pa.us
Whole thread Raw
In response to Re: SIGPIPE handling  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: SIGPIPE handling
List pgsql-patches
One issue I had is in the following function.  How can I easily find the
current signal value without causing possible signal loss during
testing, or possible abort if signals were previously ignored.  I could
use sigblock, and I think that would exist on a system that doesn't have
sigaction, but is it worth the portability issue?  Does any platform
have threads and not sigaction?

---------------------------------------------------------------------------

> +
> + pqsigfunc
> + pqsignalinquire(int signo)
> + {
> + #if !defined(HAVE_POSIX_SIGNALS)
> +     pqsigfunc old;
> +
> +     /*
> +      *    We could lose a signal during this test.
> +      *    In a multi-threaded application, this might
> +      *    be a problem.  Do any non-threaded platforms
> +      *    lack sigaction()?
> +      */
> +      old = signal(signo, SIG_IGN);
> +     signal(signo, old);
> +     return old;
> + #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

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: SIGPIPE handling
Next
From: Zach Irmen
Date:
Subject: psql error in \? output on \w line