• Tom Lane's avatar
    Don't run atexit callbacks during signal exits from ProcessStartupPacket. · 6693a96b
    Tom Lane authored
    Although 58c6fecc fixed the case for SIGQUIT, we were still calling
    proc_exit() from signal handlers for SIGTERM and timeout failures in
    ProcessStartupPacket.  Fortunately, at the point where that code runs,
    we haven't yet connected to shared memory in any meaningful way, so
    there is nothing we need to undo in shared memory.  This means it
    should be safe to use _exit(1) here, ie, not run any atexit handlers
    but also inform the postmaster that it's not a crash exit.
    
    To make sure nobody breaks the "nothing to undo" expectation, add
    a cross-check that no on-shmem-exit or before-shmem-exit handlers
    have been registered yet when we finish using these signal handlers.
    
    This change is simple enough that maybe it could be back-patched,
    but I won't risk that right now.
    
    Discussion: https://postgr.es/m/1850884.1599601164@sss.pgh.pa.us
    6693a96b
ipc.h 2.75 KB