Re: SIGPIPE handling

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>, Manfred Spraul <manfred(at)colorfullife(dot)com>
Subject: Re: SIGPIPE handling
Date: 2004-01-07 23:08:00
Message-ID: 200401072308.i07N80v22744@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Zach Irmen 2004-01-08 03:34:24 psql error in \? output on \w line
Previous Message Bruce Momjian 2004-01-07 21:52:38 Re: SIGPIPE handling