1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-03 15:22:11 +03:00

Provide sigaction() for Windows.

Commit 9abb2bfc left behind code to block signals inside signal
handlers on Windows, because our signal porting layer didn't have
sigaction().  Provide a minimal implementation that is capable of
blocking signals, to get rid of platform differences.  See also related
commit c94ae9d8.

Discussion: https://postgr.es/m/CA%2BhUKGKKKfcgx6jzok9AYenp2TNti_tfs8FMoJpL8%2B0Gsy%3D%3D_A%40mail.gmail.com
This commit is contained in:
Thomas Munro
2022-11-09 13:05:16 +13:00
parent 6bbd8b7385
commit b28ac1d24d
5 changed files with 53 additions and 79 deletions

View File

@@ -29,7 +29,9 @@
#include <signal.h>
#if !defined(WIN32) || defined(FRONTEND)
#ifndef FRONTEND
#include "libpq/pqsignal.h"
#endif
/*
* Set up a signal handler, with SA_RESTART, for signal "signo"
@@ -39,7 +41,7 @@
pqsigfunc
pqsignal(int signo, pqsigfunc func)
{
#ifndef WIN32
#if !(defined(WIN32) && defined(FRONTEND))
struct sigaction act,
oact;
@@ -53,9 +55,8 @@ pqsignal(int signo, pqsigfunc func)
if (sigaction(signo, &act, &oact) < 0)
return SIG_ERR;
return oact.sa_handler;
#else /* WIN32 */
#else
/* Forward to Windows native signal system. */
return signal(signo, func);
#endif
}
#endif /* !defined(WIN32) || defined(FRONTEND) */