20 #ifdef HAVE_SYS_PRCTL_H
21 #include <sys/prctl.h>
66 #define PM_CHILD_UNUSED 0
67 #define PM_CHILD_ASSIGNED 1
68 #define PM_CHILD_ACTIVE 2
69 #define PM_CHILD_WALSENDER 3
98 #ifdef USE_POSTMASTER_DEATH_SIGNAL
99 volatile sig_atomic_t postmaster_possibly_dead =
false;
104 postmaster_possibly_dead =
true;
116 #define POSTMASTER_DEATH_SIGNAL SIGINFO
117 #elif defined(SIGPWR)
118 #define POSTMASTER_DEATH_SIGNAL SIGPWR
120 #error "cannot find a signal to use for postmaster death"
138 sizeof(sig_atomic_t)));
275 elog(
FATAL,
"no free slots in PMChildFlags array");
333 Assert(slot > 0 && slot <= PMSignalState->num_child_flags);
354 Assert(slot > 0 && slot <= PMSignalState->num_child_flags);
369 Assert(slot > 0 && slot <= PMSignalState->num_child_flags);
387 #ifdef USE_POSTMASTER_DEATH_SIGNAL
393 postmaster_possibly_dead =
false;
416 #ifdef USE_POSTMASTER_DEATH_SIGNAL
417 postmaster_possibly_dead =
true;
421 elog(
FATAL,
"read on postmaster death monitoring pipe failed: %m");
423 elog(
FATAL,
"unexpected data in postmaster death monitoring pipe");
430 if (WaitForSingleObject(PostmasterHandle, 0) == WAIT_TIMEOUT)
434 #ifdef USE_POSTMASTER_DEATH_SIGNAL
435 postmaster_possibly_dead =
true;
448 #ifdef USE_POSTMASTER_DEATH_SIGNAL
449 int signum = POSTMASTER_DEATH_SIGNAL;
452 pqsignal(signum, postmaster_death_handler);
455 #if defined(PR_SET_PDEATHSIG)
456 if (prctl(PR_SET_PDEATHSIG, signum) < 0)
457 elog(
ERROR,
"could not request parent death signal: %m");
458 #elif defined(PROC_PDEATHSIG_CTL)
459 if (procctl(P_PID, 0, PROC_PDEATHSIG_CTL, &signum) < 0)
460 elog(
ERROR,
"could not request parent death signal: %m");
462 #error "USE_POSTMASTER_DEATH_SIGNAL set, but there is no mechanism to request the signal"
469 postmaster_possibly_dead =
true;
#define unvolatize(underlying_type, expr)
#define Assert(condition)
#define FLEXIBLE_ARRAY_MEMBER
#define MemSet(start, val, len)
void on_shmem_exit(pg_on_exit_callback function, Datum arg)
void pfree(void *pointer)
void * MemoryContextAllocZero(MemoryContext context, Size size)
MemoryContext PostmasterContext
static bool * PMChildInUse
#define PM_CHILD_WALSENDER
static int num_child_inuse
static int next_child_inuse
Size PMSignalShmemSize(void)
bool ReleasePostmasterChildSlot(int slot)
bool CheckPostmasterSignal(PMSignalReason reason)
static void MarkPostmasterChildInactive(int code, Datum arg)
bool PostmasterIsAliveInternal(void)
QuitSignalReason GetQuitSignalReason(void)
void SendPostmasterSignal(PMSignalReason reason)
void SetQuitSignalReason(QuitSignalReason reason)
NON_EXEC_STATIC volatile PMSignalData * PMSignalState
void MarkPostmasterChildWalSender(void)
bool IsPostmasterChildWalSender(int slot)
void RegisterPostmasterChildActive(void)
void PostmasterDeathSignalInit(void)
int AssignPostmasterChildSlot(void)
void PMSignalShmemInit(void)
#define PM_CHILD_ASSIGNED
pqsigfunc pqsignal(int signo, pqsigfunc func)
int postmaster_alive_fds[2]
int MaxLivePostmasterChildren(void)
#define POSTMASTER_FD_WATCH
Size add_size(Size s1, Size s2)
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
Size mul_size(Size s1, Size s2)
static pg_noinline void Size size
sig_atomic_t PMSignalFlags[NUM_PMSIGNALS]
sig_atomic_t PMChildFlags[FLEXIBLE_ARRAY_MEMBER]
QuitSignalReason sigquit_reason