PostgreSQL Source Code  git master
pqsignal.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * pqsignal.h
4  * Backend signal(2) support (see also src/port/pqsignal.c)
5  *
6  * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  * src/include/libpq/pqsignal.h
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef PQSIGNAL_H
14 #define PQSIGNAL_H
15 
16 #include <signal.h>
17 
18 #define PG_SETMASK(mask) sigprocmask(SIG_SETMASK, mask, NULL)
19 
20 #ifdef WIN32
21 /* Emulate POSIX sigset_t APIs on Windows */
22 typedef int sigset_t;
23 
24 #define SA_RESTART 1
25 #define SA_NODEFER 2
26 
27 struct sigaction
28 {
29  void (*sa_handler) (int);
30  /* sa_sigaction not yet implemented */
31  sigset_t sa_mask;
32  int sa_flags;
33 };
34 
35 extern int pqsigprocmask(int how, const sigset_t *set, sigset_t *oset);
36 extern int pqsigaction(int signum, const struct sigaction *act,
37  struct sigaction *oldact);
38 
39 #define SIG_BLOCK 1
40 #define SIG_UNBLOCK 2
41 #define SIG_SETMASK 3
42 #define sigprocmask(how, set, oset) pqsigprocmask((how), (set), (oset))
43 #define sigaction(signum, act, oldact) pqsigaction((signum), (act), (oldact))
44 #define sigemptyset(set) (*(set) = 0)
45 #define sigfillset(set) (*(set) = ~0)
46 #define sigaddset(set, signum) (*(set) |= (sigmask(signum)))
47 #define sigdelset(set, signum) (*(set) &= ~(sigmask(signum)))
48 #endif /* WIN32 */
49 
50 extern PGDLLIMPORT sigset_t UnBlockSig;
51 extern PGDLLIMPORT sigset_t BlockSig;
52 extern PGDLLIMPORT sigset_t StartupBlockSig;
53 
54 extern void pqinitmask(void);
55 
56 /* pqsigfunc is declared in src/include/port.h */
57 extern pqsigfunc pqsignal_pm(int signo, pqsigfunc func);
58 
59 #endif /* PQSIGNAL_H */
#define PGDLLIMPORT
Definition: c.h:1252
void(* pqsigfunc)(SIGNAL_ARGS)
Definition: port.h:488
void pqinitmask(void)
Definition: pqsignal.c:41
PGDLLIMPORT sigset_t BlockSig
Definition: pqsignal.c:23
pqsigfunc pqsignal_pm(int signo, pqsigfunc func)
Definition: pqsignal.c:115
PGDLLIMPORT sigset_t UnBlockSig
Definition: pqsignal.c:22
PGDLLIMPORT sigset_t StartupBlockSig
Definition: pqsignal.c:24
int pqsigaction(int signum, const struct sigaction *act, struct sigaction *oldact)
Definition: signal.c:210
int pqsigprocmask(int how, const sigset_t *set, sigset_t *oset)
Definition: signal.c:171