In the 90s we needed to deal with computers that still had the
pre-standard signal masking APIs. That hasn't been relevant for a very
long time on Unix systems, and
c94ae9d8 got rid of a remaining
dependency in our Windows porting code. PG_SETMASK didn't expose
save/restore functionality, so we'd already started using sigprocmask()
directly in places, creating the visual distraction of having two ways
to spell it. It's not part of the API that extensions are expected to
be using (but if they are, the change will be trivial). It seems like a
good time to drop the old macro and just call the standard POSIX
function.
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Discussion: https://postgr.es/m/CA%2BhUKG%2BKfQgrhHP2DLTohX1WwubaCBHmTzGnAEDPZ-Gug-Xskg%40mail.gmail.com
* handler. We do this fairly early in the sequence so that the timeout
* infrastructure will be functional if needed while aborting.
*/
- PG_SETMASK(&UnBlockSig);
+ sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
/*
* check the current transaction state
* handler. We do this fairly early in the sequence so that the timeout
* infrastructure will be functional if needed while aborting.
*/
- PG_SETMASK(&UnBlockSig);
+ sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
/*
* check the current transaction state
PG_exception_stack = &local_sigjmp_buf;
/* must unblock signals before calling rebuild_database_list */
- PG_SETMASK(&UnBlockSig);
+ sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
/*
* Set always-secure search path. Launcher doesn't connect to a database,
/* We can now handle ereport(ERROR) */
PG_exception_stack = &local_sigjmp_buf;
- PG_SETMASK(&UnBlockSig);
+ sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
/*
* Set always-secure search path, so malicious users can't redirect user
static void
bgworker_die(SIGNAL_ARGS)
{
- PG_SETMASK(&BlockSig);
+ sigprocmask(SIG_SETMASK, &BlockSig, NULL);
ereport(FATAL,
(errcode(ERRCODE_ADMIN_SHUTDOWN),
/*
* Unblock signals (they were blocked when the postmaster forked us)
*/
- PG_SETMASK(&UnBlockSig);
+ sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
/*
* Reset hibernation state after any error.
/*
* Unblock signals (they were blocked when the postmaster forked us)
*/
- PG_SETMASK(&UnBlockSig);
+ sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
/*
* Ensure all shared memory values are set correctly for the config. Doing
pqsignal(SIGCHLD, SIG_DFL);
/* Unblock signals (they were blocked when the postmaster forked us) */
- PG_SETMASK(&UnBlockSig);
+ sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
/* We shouldn't be launched unnecessarily. */
Assert(XLogArchivingActive());
* postmaster/bgworker.c and postmaster/checkpointer.c.
*/
pqinitmask();
- PG_SETMASK(&BlockSig);
+ sigprocmask(SIG_SETMASK, &BlockSig, NULL);
pqsignal(SIGHUP, handle_pm_reload_request_signal);
pqsignal(SIGINT, handle_pm_shutdown_request_signal);
#endif
/* Begin accepting signals. */
- PG_SETMASK(&UnBlockSig);
+ sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
/*
* Options setup
pqsignal(SIGTERM, process_startup_packet_die);
/* SIGQUIT handler was already set up by InitPostmasterChild */
InitializeTimeouts(); /* establishes SIGALRM handler */
- PG_SETMASK(&StartupBlockSig);
+ sigprocmask(SIG_SETMASK, &StartupBlockSig, NULL);
/*
* Get the remote host name and port for logging and status display.
* Disable the timeout, and prevent SIGTERM again.
*/
disable_timeout(STARTUP_PACKET_TIMEOUT, false);
- PG_SETMASK(&BlockSig);
+ sigprocmask(SIG_SETMASK, &BlockSig, NULL);
/*
* As a safety check that nothing in startup has yet performed
void
BackgroundWorkerBlockSignals(void)
{
- PG_SETMASK(&BlockSig);
+ sigprocmask(SIG_SETMASK, &BlockSig, NULL);
}
void
BackgroundWorkerUnblockSignals(void)
{
- PG_SETMASK(&UnBlockSig);
+ sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
}
#ifdef EXEC_BACKEND
/*
* Unblock signals (they were blocked when the postmaster forked us)
*/
- PG_SETMASK(&UnBlockSig);
+ sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
/*
* Do what we came for.
*/
pqsignal(SIGCHLD, SIG_DFL);
- PG_SETMASK(&UnBlockSig);
+ sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
#ifdef WIN32
/* Fire up separate data transfer thread */
/*
* Unblock signals (they were blocked when the postmaster forked us)
*/
- PG_SETMASK(&UnBlockSig);
+ sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
/*
* Reset hibernation state after any error.
elog(ERROR, "libpqwalreceiver didn't initialize correctly");
/* Unblock signals (they were blocked when the postmaster forked us) */
- PG_SETMASK(&UnBlockSig);
+ sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
/* Establish the connection to the primary for XLOG streaming */
wrconn = walrcv_connect(conninfo, false,
quickdie(SIGNAL_ARGS)
{
sigaddset(&BlockSig, SIGQUIT); /* prevent nested calls */
- PG_SETMASK(&BlockSig);
+ sigprocmask(SIG_SETMASK, &BlockSig, NULL);
/*
* Prevent interrupts while exiting; though we just blocked signals that
BaseInit();
/* We need to allow SIGINT, etc during the initial transaction */
- PG_SETMASK(&UnBlockSig);
+ sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
/*
* General initialization.
pqsignal(SIGQUIT, SignalHandlerForCrashExit);
sigdelset(&BlockSig, SIGQUIT);
- PG_SETMASK(&BlockSig);
+ sigprocmask(SIG_SETMASK, &BlockSig, NULL);
/* Request a signal if the postmaster dies, if possible. */
PostmasterDeathSignalInit();
* But we don't unblock SIGQUIT or provide a default handler for it.
*/
pqinitmask();
- PG_SETMASK(&BlockSig);
+ sigprocmask(SIG_SETMASK, &BlockSig, NULL);
/* Compute paths, no postmaster to inherit from */
if (my_exec_path[0] == '\0')
#include <signal.h>
-#define PG_SETMASK(mask) sigprocmask(SIG_SETMASK, mask, NULL)
-
#ifdef WIN32
/* Emulate POSIX sigset_t APIs on Windows */
typedef int sigset_t;