Hi,
On 2025-09-22 17:23:33 +0200, Álvaro Herrera wrote:
> On 2025-Sep-18, Robert Haas wrote:
>
> > I submit that we should not have both a comment that says we must save
> > and restore errno and code that doesn't. Maybe the comment is intended
> > to imply that the caller should be doing such a save and restore, but
> > if so, then (a) that's not very clear from the wording and (b) why the
> > XXX?
>
> I understand the comment as saying that the caller should do
> save/restore of errno. However, looking at several places that are
> calling SetLatch() (which is the only caller of this function) it
> appears that at least several of them have actually forgotten to do so
> (didn't scan all of them but checked a couple and they weren't doing
> it). I think what you have found is not just a bogus comment, but an
> actual bug or class of bugs.
These days pqsignal saves/restores errno in a wrapper around signal
handlers. So at least in newer branches this shouldn't be an issue when called
from signal handlers.
Greetings,
Andres Freund