Re: common signal handler protection

Nathan Bossart <nathandbossart@gmail.com>

From: Nathan Bossart <nathandbossart@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@postgresql.org, noah@leadboat.com
Date: 2024-02-07T17:15:54Z
Lists: pgsql-hackers
Sorry for the noise.

On Wed, Feb 07, 2024 at 11:06:50AM -0600, Nathan Bossart wrote:
> I'd like to get this committed (to HEAD only) in the next few weeks.  TBH
> I'm not wild about the weird caveats (e.g., race conditions when pqsignal()
> is called within a signal handler), but I also think it is unlikely that
> they cause any issues in practice.  Please do let me know if you have any
> concerns about this.

Perhaps we should add a file global bool that is only set during
wrapper_handler().  Then we could Assert() or elog(ERROR, ...) if
pqsignal() is called with it set.

-- 
Nathan Bossart
Amazon Web Services: https://aws.amazon.com



Commits

  1. Remove obsolete check in SIGTERM handler for the startup process.

  2. Centralize logic for restoring errno in signal handlers.

  3. Check that MyProcPid == getpid() in backend signal handlers.

  4. Avoid calling proc_exit() in processes forked by system().