62 SleepEx((microsec < 500 ? 1 : (microsec + 500) / 1000), FALSE);
67 (microsec < 500 ? 1 : (microsec + 500) / 1000))
82 HANDLE signal_thread_handle;
100 (
errmsg_internal(
"could not create signal event: error code %lu", GetLastError())));
103 signal_thread_handle = CreateThread(NULL, 0,
pg_signal_thread, NULL, 0, NULL);
104 if (signal_thread_handle == NULL)
149 block_mask = act->sa_mask;
150 if ((act->sa_flags & SA_NODEFER) == 0)
153 sigprocmask(SIG_BLOCK, &block_mask, &save_mask);
155 sigprocmask(SIG_SETMASK, &save_mask, NULL);
211 struct sigaction *oldact)
232 snprintf(pipename,
sizeof(pipename),
"\\\\.\\pipe\\pgsignal_%u", (
int) pid);
234 pipe = CreateNamedPipe(pipename, PIPE_ACCESS_DUPLEX,
235 PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
236 PIPE_UNLIMITED_INSTANCES, 16, 16, 1000, NULL);
238 if (pipe == INVALID_HANDLE_VALUE)
240 (
errmsg(
"could not create signal listener pipe for PID %d: error code %lu",
241 (
int) pid, GetLastError())));
280 snprintf(pipename,
sizeof(pipename),
"\\\\.\\pipe\\pgsignal_%lu", GetCurrentProcessId());
287 if (pipe == INVALID_HANDLE_VALUE)
289 pipe = CreateNamedPipe(pipename, PIPE_ACCESS_DUPLEX,
290 PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
291 PIPE_UNLIMITED_INSTANCES, 16, 16, 1000, NULL);
293 if (pipe == INVALID_HANDLE_VALUE)
295 write_stderr(
"could not create signal listener pipe: error code %lu; retrying\n", GetLastError());
306 fConnected = ConnectNamedPipe(pipe, NULL) ? TRUE : (GetLastError() == ERROR_PIPE_CONNECTED);
315 if (ReadFile(pipe, &sigNum, 1, &bytes, NULL) &&
333 WriteFile(pipe, &sigNum, 1, &bytes, NULL);
342 FlushFileBuffers(pipe);
354 DisconnectNamedPipe(pipe);
367 pipe = INVALID_HANDLE_VALUE;
379 if (dwCtrlType == CTRL_C_EVENT ||
380 dwCtrlType == CTRL_BREAK_EVENT ||
381 dwCtrlType == CTRL_CLOSE_EVENT ||
382 dwCtrlType == CTRL_SHUTDOWN_EVENT)
#define write_stderr(str)
#define Assert(condition)
int errmsg_internal(const char *fmt,...)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void(* pqsigfunc)(SIGNAL_ARGS)
HANDLE pgwin32_create_signal_listener(pid_t pid)
static DWORD WINAPI pg_signal_thread(LPVOID param)
int pqsigaction(int signum, const struct sigaction *act, struct sigaction *oldact)
static struct sigaction pg_signal_array[PG_SIGNAL_COUNT]
void pg_queue_signal(int signum)
void pg_usleep(long microsec)
volatile int pg_signal_queue
HANDLE pgwin32_initial_signal_pipe
static CRITICAL_SECTION pg_signal_crit_sec
static BOOL WINAPI pg_console_handler(DWORD dwCtrlType)
static pqsigfunc pg_signal_defaults[PG_SIGNAL_COUNT]
void pgwin32_dispatch_queued_signals(void)
HANDLE pgwin32_signal_event
int pqsigprocmask(int how, const sigset_t *set, sigset_t *oset)
void pgwin32_signal_initialize(void)
#define UNBLOCKED_SIGNAL_QUEUE()