Tom Lane wrote:
>Manfred Spraul <manfred@colorfullife.com> writes:
>
>
>>For multithreaded apps, this is not possible: sigaction is per process.
>>Thus the calling application must handle the SIGPIPE signals for libpq -
>>either by blocking or ignoring them. We are still discussing the exact
>>API. Probably a global state that is accessible through a new function.
>>
>>
>
>I think we should also take a hard look at avoiding the problem by using
>MSG_NOSIGNAL on platforms that have it,
>
I think that's the second step. First we need a portable solution, then
we can optimize it.
The fastest solution is one signal(SIGPIPE, SIG_IGN) in main(), but that
requires a change in all libpq users. OTHO there shouldn't be that many
multithreaded users.
sigprocmask + sigwait could work, but sigprocmask is undefined if
multiple threads are running. Is there a portable approach for weak
links? libpq would have to call proc_sigmask if linked against
libpthread, and sigprocmask if not linked against libpthread. With gcc,
I could use 'void proc_sigmask () __attribute__ ((weak, alias
("_sigprocmask")));' or something similar, but this wouldn't be portable
either.
-- Manfred