Manfred Spraul <manfred@colorfullife.com> writes:
> What about multithreaded apps?
> old = pgsignal(SIPEPIPE, SIG_IGN);
> ** another thread calls sigaction(SIGPIPE,,);
> pgsignal(SIGPIPE, old);
> And the signal state is corrupted.
If other threads are changing the signal state mid-flight, we are
screwed anyway; if not here then later when we are doing sends,
or even more directly because our test here may not reflect reality
later.
I don't think we need to complicate pqsignal's API for this. Instead
we'd better document that SIGPIPE handling has to be set up and kept
stable before doing any libpq operations in a multithread app.
regards, tom lane