PostgreSQL Source Code  git master
pqsignal.h File Reference
#include <signal.h>
Include dependency graph for pqsignal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PG_SETMASK(mask)   sigprocmask(SIG_SETMASK, mask, NULL)
 

Functions

void pqinitmask (void)
 
pqsigfunc pqsignal_pm (int signo, pqsigfunc func)
 

Variables

PGDLLIMPORT sigset_t UnBlockSig
 
PGDLLIMPORT sigset_t BlockSig
 
PGDLLIMPORT sigset_t StartupBlockSig
 

Macro Definition Documentation

◆ PG_SETMASK

#define PG_SETMASK (   mask)    sigprocmask(SIG_SETMASK, mask, NULL)

Definition at line 19 of file pqsignal.h.

Function Documentation

◆ pqinitmask()

void pqinitmask ( void  )

Definition at line 41 of file pqsignal.c.

42 {
43  sigemptyset(&UnBlockSig);
44 
45  /* Note: InitializeLatchSupport() modifies UnBlockSig. */
46 
47  /* First set all signals, then clear some. */
48  sigfillset(&BlockSig);
49  sigfillset(&StartupBlockSig);
50 
51  /*
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...
55  */
56 #ifdef SIGTRAP
57  sigdelset(&BlockSig, SIGTRAP);
58  sigdelset(&StartupBlockSig, SIGTRAP);
59 #endif
60 #ifdef SIGABRT
61  sigdelset(&BlockSig, SIGABRT);
62  sigdelset(&StartupBlockSig, SIGABRT);
63 #endif
64 #ifdef SIGILL
65  sigdelset(&BlockSig, SIGILL);
66  sigdelset(&StartupBlockSig, SIGILL);
67 #endif
68 #ifdef SIGFPE
69  sigdelset(&BlockSig, SIGFPE);
70  sigdelset(&StartupBlockSig, SIGFPE);
71 #endif
72 #ifdef SIGSEGV
73  sigdelset(&BlockSig, SIGSEGV);
74  sigdelset(&StartupBlockSig, SIGSEGV);
75 #endif
76 #ifdef SIGBUS
77  sigdelset(&BlockSig, SIGBUS);
78  sigdelset(&StartupBlockSig, SIGBUS);
79 #endif
80 #ifdef SIGSYS
81  sigdelset(&BlockSig, SIGSYS);
82  sigdelset(&StartupBlockSig, SIGSYS);
83 #endif
84 #ifdef SIGCONT
85  sigdelset(&BlockSig, SIGCONT);
86  sigdelset(&StartupBlockSig, SIGCONT);
87 #endif
88 
89 /* Signals unique to startup */
90 #ifdef SIGQUIT
91  sigdelset(&StartupBlockSig, SIGQUIT);
92 #endif
93 #ifdef SIGTERM
94  sigdelset(&StartupBlockSig, SIGTERM);
95 #endif
96 #ifdef SIGALRM
97  sigdelset(&StartupBlockSig, SIGALRM);
98 #endif
99 }
sigset_t StartupBlockSig
Definition: pqsignal.c:24
sigset_t UnBlockSig
Definition: pqsignal.c:22
sigset_t BlockSig
Definition: pqsignal.c:23
#define SIGCONT
Definition: win32_port.h:176
#define SIGQUIT
Definition: win32_port.h:168
#define SIGTRAP
Definition: win32_port.h:169
#define SIGALRM
Definition: win32_port.h:173
#define SIGABRT
Definition: win32_port.h:170

References BlockSig, SIGABRT, SIGALRM, SIGCONT, SIGQUIT, SIGTRAP, StartupBlockSig, and UnBlockSig.

Referenced by InitPostmasterChild(), InitStandaloneProcess(), and PostmasterMain().

◆ pqsignal_pm()

pqsigfunc pqsignal_pm ( int  signo,
pqsigfunc  func 
)

Definition at line 120 of file pqsignal.c.

121 {
122 #ifndef WIN32
123  struct sigaction act,
124  oact;
125 
126  act.sa_handler = func;
127  if (func == SIG_IGN || func == SIG_DFL)
128  {
129  /* in these cases, act the same as pqsignal() */
130  sigemptyset(&act.sa_mask);
131  act.sa_flags = SA_RESTART;
132  }
133  else
134  {
135  act.sa_mask = BlockSig;
136  act.sa_flags = 0;
137  }
138 #ifdef SA_NOCLDSTOP
139  if (signo == SIGCHLD)
140  act.sa_flags |= SA_NOCLDSTOP;
141 #endif
142  if (sigaction(signo, &act, &oact) < 0)
143  return SIG_ERR;
144  return oact.sa_handler;
145 #else /* WIN32 */
146  return pqsignal(signo, func);
147 #endif
148 }
pqsigfunc pqsignal(int signo, pqsigfunc func)
Definition: pqsignal.c:40
#define SIGCHLD
Definition: win32_port.h:177
#define SIG_DFL
Definition: win32_port.h:162
#define SIG_ERR
Definition: win32_port.h:163
#define SIG_IGN
Definition: win32_port.h:164

References BlockSig, pqsignal(), SIG_DFL, SIG_ERR, SIG_IGN, and SIGCHLD.

Referenced by PostmasterMain().

Variable Documentation

◆ BlockSig

◆ StartupBlockSig

PGDLLIMPORT sigset_t StartupBlockSig
extern

Definition at line 24 of file pqsignal.c.

Referenced by BackendInitialize(), and pqinitmask().

◆ UnBlockSig