1 /*-------------------------------------------------------------------------
4 * Backend signal(2) support (see also src/port/pqsignal.c)
6 * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
11 * src/backend/libpq/pqsignal.c
13 * ------------------------------------------------------------------------
18 #include "libpq/pqsignal.h"
21 /* Global variables */
28 * Initialize BlockSig, UnBlockSig, and StartupBlockSig.
30 * BlockSig is the set of signals to block when we are trying to block
31 * signals. This includes all signals we normally expect to get, but NOT
32 * signals that should never be turned off.
34 * StartupBlockSig is the set of signals to block during startup packet
35 * collection; it's essentially BlockSig minus SIGTERM, SIGQUIT, SIGALRM.
37 * UnBlockSig is the set of signals to block when we don't want to block
43 sigemptyset(&UnBlockSig
);
45 /* Note: InitializeLatchSupport() modifies UnBlockSig. */
47 /* First set all signals, then clear some. */
48 sigfillset(&BlockSig
);
49 sigfillset(&StartupBlockSig
);
52 * Unmark those signals that should never be blocked. Some of these signal
53 * names don't exist on all platforms. Most do, but might as well ifdef
54 * them all for consistency...
57 sigdelset(&BlockSig
, SIGTRAP
);
58 sigdelset(&StartupBlockSig
, SIGTRAP
);
61 sigdelset(&BlockSig
, SIGABRT
);
62 sigdelset(&StartupBlockSig
, SIGABRT
);
65 sigdelset(&BlockSig
, SIGILL
);
66 sigdelset(&StartupBlockSig
, SIGILL
);
69 sigdelset(&BlockSig
, SIGFPE
);
70 sigdelset(&StartupBlockSig
, SIGFPE
);
73 sigdelset(&BlockSig
, SIGSEGV
);
74 sigdelset(&StartupBlockSig
, SIGSEGV
);
77 sigdelset(&BlockSig
, SIGBUS
);
78 sigdelset(&StartupBlockSig
, SIGBUS
);
81 sigdelset(&BlockSig
, SIGSYS
);
82 sigdelset(&StartupBlockSig
, SIGSYS
);
85 sigdelset(&BlockSig
, SIGCONT
);
86 sigdelset(&StartupBlockSig
, SIGCONT
);
89 /* Signals unique to startup */
91 sigdelset(&StartupBlockSig
, SIGQUIT
);
94 sigdelset(&StartupBlockSig
, SIGTERM
);
97 sigdelset(&StartupBlockSig
, SIGALRM
);