diff options
author | Thomas Munro | 2018-07-11 00:47:42 +0000 |
---|---|---|
committer | Thomas Munro | 2018-07-11 01:14:07 +0000 |
commit | f98b8476cd4a19dfc602ab95642ce08e53877d65 (patch) | |
tree | 8e47d857238724401ab000ab240af1b55ecaf595 /src | |
parent | 9f09529952ac41a10e5874cba745c1c24e67ac79 (diff) |
Use signals for postmaster death on FreeBSD.
Use FreeBSD 11.2's new support for detecting parent process death to
make PostmasterIsAlive() very cheap, as was done for Linux in an
earlier commit.
Author: Thomas Munro
Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/storage/ipc/pmsignal.c | 3 | ||||
-rw-r--r-- | src/include/pg_config.h.in | 3 | ||||
-rw-r--r-- | src/include/storage/pmsignal.h | 7 |
3 files changed, 12 insertions, 1 deletions
diff --git a/src/backend/storage/ipc/pmsignal.c b/src/backend/storage/ipc/pmsignal.c index ebf027306f7..f658588c272 100644 --- a/src/backend/storage/ipc/pmsignal.c +++ b/src/backend/storage/ipc/pmsignal.c @@ -379,6 +379,9 @@ PostmasterDeathSignalInit(void) #if defined(PR_SET_PDEATHSIG) if (prctl(PR_SET_PDEATHSIG, signum) < 0) elog(ERROR, "could not request parent death signal: %m"); +#elif defined(PROC_PDEATHSIG_CTL) + if (procctl(P_PID, 0, PROC_PDEATHSIG_CTL, &signum) < 0) + elog(ERROR, "could not request parent death signal: %m"); #else #error "USE_POSTMASTER_DEATH_SIGNAL set, but there is no mechanism to request the signal" #endif diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index 4ef53416785..f9fb92f31c1 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -603,6 +603,9 @@ /* Define to 1 if you have the <sys/prctl.h> header file. */ #undef HAVE_SYS_PRCTL_H +/* Define to 1 if you have the <sys/procctl.h> header file. */ +#undef HAVE_SYS_PROCCTL_H + /* Define to 1 if you have the <sys/pstat.h> header file. */ #undef HAVE_SYS_PSTAT_H diff --git a/src/include/storage/pmsignal.h b/src/include/storage/pmsignal.h index 54e7108ac0b..5ecc1b757c8 100644 --- a/src/include/storage/pmsignal.h +++ b/src/include/storage/pmsignal.h @@ -18,6 +18,10 @@ #include "sys/prctl.h" #endif +#ifdef HAVE_SYS_PROCCTL_H +#include "sys/procctl.h" +#endif + /* * Reasons for signaling the postmaster. We can cope with simultaneous * signals for different reasons. If the same reason is signaled multiple @@ -66,7 +70,8 @@ extern void PostmasterDeathSignalInit(void); * the parent dies. Checking the flag first makes PostmasterIsAlive() a lot * cheaper in usual case that the postmaster is alive. */ -#if defined(HAVE_SYS_PRCTL_H) && defined(PR_SET_PDEATHSIG) +#if (defined(HAVE_SYS_PRCTL_H) && defined(PR_SET_PDEATHSIG)) || \ + (defined(HAVE_SYS_PROCCTL_H) && defined(PROC_PDEATHSIG_CTL)) #define USE_POSTMASTER_DEATH_SIGNAL #endif |