Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Munro2022-07-16 04:07:45 +0000
committerThomas Munro2022-07-16 05:03:38 +0000
commitc94ae9d827a360d74da6a304692d34a4dc8b6445 (patch)
tree491e7d2ab3499968d9d32978d23bdc7701124859 /src/backend
parent3b8d23a3e14f05890f1f306902cd4b992beeee71 (diff)
Emulate sigprocmask(), not sigsetmask(), on Windows.
Since commit a65e0864, we've required Unix systems to have sigprocmask(). As noted in that commit's message, we were still emulating the historical pre-standard sigsetmask() function in our Windows support code. Emulate standard sigprocmask() instead, for consistency. The PG_SETMASK() abstraction is now redundant and all calls could in theory be replaced by plain sigprocmask() calls, but that isn't done by this commit. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/3153247.1657834482%40sss.pgh.pa.us
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/port/win32/signal.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/backend/port/win32/signal.c b/src/backend/port/win32/signal.c
index b71164d8dbd..53b93a50b26 100644
--- a/src/backend/port/win32/signal.c
+++ b/src/backend/port/win32/signal.c
@@ -112,7 +112,7 @@ pgwin32_signal_initialize(void)
/*
* Dispatch all signals currently queued and not blocked
* Blocked signals are ignored, and will be fired at the time of
- * the pqsigsetmask() call.
+ * the pqsigprocmask() call.
*/
void
pgwin32_dispatch_queued_signals(void)
@@ -154,12 +154,29 @@ pgwin32_dispatch_queued_signals(void)
/* signal masking. Only called on main thread, no sync required */
int
-pqsigsetmask(int mask)
+pqsigprocmask(int how, const sigset_t *set, sigset_t *oset)
{
- int prevmask;
+ if (oset)
+ *oset = pg_signal_mask;
- prevmask = pg_signal_mask;
- pg_signal_mask = mask;
+ if (!set)
+ return 0;
+
+ switch (how)
+ {
+ case SIG_BLOCK:
+ pg_signal_mask |= *set;
+ break;
+ case SIG_UNBLOCK:
+ pg_signal_mask &= ~*set;
+ break;
+ case SIG_SETMASK:
+ pg_signal_mask = *set;
+ break;
+ default:
+ errno = EINVAL;
+ return -1;
+ }
/*
* Dispatch any signals queued up right away, in case we have unblocked
@@ -167,7 +184,7 @@ pqsigsetmask(int mask)
*/
pgwin32_dispatch_queued_signals();
- return prevmask;
+ return 0;
}