Skip to content

Commit f333204

Browse files
committed
Actually, it's not that hard to merge the Windows pqsignal code ...
... just need to typedef sigset_t and provide sigemptyset/sigfillset, which are easy enough.
1 parent 2c713d6 commit f333204

File tree

2 files changed

+10
-35
lines changed

2 files changed

+10
-35
lines changed

src/backend/libpq/pqsignal.c

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,10 @@
1818
#include "libpq/pqsignal.h"
1919

2020

21-
#ifndef WIN32
21+
/* Global variables */
2222
sigset_t UnBlockSig,
2323
BlockSig,
2424
StartupBlockSig;
25-
#else
26-
int UnBlockSig,
27-
BlockSig,
28-
StartupBlockSig;
29-
#endif
3025

3126

3227
/*
@@ -45,8 +40,6 @@ int UnBlockSig,
4540
void
4641
pqinitmask(void)
4742
{
48-
#ifndef WIN32
49-
5043
sigemptyset(&UnBlockSig);
5144

5245
/* First set all signals, then clear some. */
@@ -101,19 +94,4 @@ pqinitmask(void)
10194
#ifdef SIGALRM
10295
sigdelset(&StartupBlockSig, SIGALRM);
10396
#endif
104-
#else /* WIN32 */
105-
/* Set the signals we want. */
106-
UnBlockSig = 0;
107-
BlockSig = sigmask(SIGQUIT) |
108-
sigmask(SIGTERM) | sigmask(SIGALRM) |
109-
/* common signals between two */
110-
sigmask(SIGHUP) |
111-
sigmask(SIGINT) | sigmask(SIGUSR1) |
112-
sigmask(SIGUSR2) | sigmask(SIGCHLD) |
113-
sigmask(SIGWINCH) | sigmask(SIGFPE);
114-
StartupBlockSig = sigmask(SIGHUP) |
115-
sigmask(SIGINT) | sigmask(SIGUSR1) |
116-
sigmask(SIGUSR2) | sigmask(SIGCHLD) |
117-
sigmask(SIGWINCH) | sigmask(SIGFPE);
118-
#endif
11997
}

src/include/libpq/pqsignal.h

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,24 @@
1616
#include <signal.h>
1717

1818
#ifndef WIN32
19-
extern sigset_t UnBlockSig,
20-
BlockSig,
21-
StartupBlockSig;
22-
2319
#define PG_SETMASK(mask) sigprocmask(SIG_SETMASK, mask, NULL)
24-
#else /* WIN32 */
25-
/*
26-
* Windows doesn't provide the POSIX signal API, so we use something
27-
* approximating the old BSD signal API.
28-
*/
29-
extern int UnBlockSig,
30-
BlockSig,
31-
StartupBlockSig;
20+
#else
21+
/* Emulate POSIX sigset_t APIs on Windows */
22+
typedef int sigset_t;
3223

3324
extern int pqsigsetmask(int mask);
3425

3526
#define PG_SETMASK(mask) pqsigsetmask(*(mask))
27+
#define sigemptyset(set) (*(set) = 0)
28+
#define sigfillset(set) (*(set) = ~0)
3629
#define sigaddset(set, signum) (*(set) |= (sigmask(signum)))
3730
#define sigdelset(set, signum) (*(set) &= ~(sigmask(signum)))
3831
#endif /* WIN32 */
3932

33+
extern sigset_t UnBlockSig,
34+
BlockSig,
35+
StartupBlockSig;
36+
4037
extern void pqinitmask(void);
4138

4239
#endif /* PQSIGNAL_H */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy