From d84d5ea5ac112c04d6f79a09115f33aadc0db1a4 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 26 Aug 2014 22:00:41 +1000 Subject: [PATCH] Actually handle signals with a graceful shutdown in ckdb --- src/ckdb.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ckdb.c b/src/ckdb.c index a7c472d8..ac5d2b82 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -10263,6 +10263,13 @@ static struct option long_options[] = { { 0, 0, 0, 0 } }; +static void sighandler(int sig) +{ + LOGWARNING("Received signal %d, shutting down", sig); + cksleep_ms(420); + exit(0); +} + int main(int argc, char **argv) { struct sigaction handler; @@ -10426,6 +10433,7 @@ int main(int argc, char **argv) create_pthread(&ckp.pth_listener, listener, &ckp.main); + handler.sa_handler = sighandler; handler.sa_flags = 0; sigemptyset(&handler.sa_mask); sigaction(SIGTERM, &handler, NULL);