Skip to content

Commit 3dfd14d

Browse files
committed
2 parents 504c5da + 1a6f111 commit 3dfd14d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

contrib/pg_dtm/sockhub/sockhub.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <stdlib.h>
1414
#include <unistd.h>
1515
#include <string.h>
16+
#include <signal.h>
1617
#include <errno.h>
1718

1819
#include "sockhub.h"
@@ -242,12 +243,23 @@ void ShubInitialize(Shub* shub, ShubParams* params)
242243
shub->out_buffer_used = 0;
243244
}
244245

246+
static int stop = 0;
247+
static void die(int sig) {
248+
stop = 1;
249+
}
245250

246251
void ShubLoop(Shub* shub)
247252
{
248253
int buffer_size = shub->params->buffer_size;
254+
signal(SIGINT, die);
255+
signal(SIGQUIT, die);
256+
signal(SIGTERM, die);
257+
signal(SIGHUP, die);
258+
sigset_t sset;
259+
sigfillset(&sset);
260+
sigprocmask(SIG_UNBLOCK, &sset, NULL);
249261

250-
while (1) {
262+
while (!stop) {
251263
fd_set events;
252264
struct timeval tm;
253265
int i, rc;

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