On 2022-Jul-15, Thomas Munro wrote:
> I checked that this throw-away assertion doesn't fail currently:
>
> if (IsUnderPostmaster)
> + {
> + sigset_t old;
> + sigprocmask(SIG_SETMASK, NULL, &old);
> + Assert(memcmp(&old, &UnBlockSig, sizeof(UnBlockSig)) == 0);
> PG_SETMASK(&BlockSig);
> + }
>
> ... but now I'm wondering if we should be more defensive and possibly
> even save/restore the mask.
Yeah, that sounds better to me.
> Originally I discounted that because I thought I had to go through
> PG_SETMASK for portability reasons, but on closer inspection, I don't
> see any reason not to use sigprocmask directly in Unix-only code.
ISTM it would be cleaner to patch PG_SETMASK to have a second argument
and to return the original mask if that's not NULL. This is more
invasive, but there aren't that many callsites of that macro.
--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/