From d0534df8c01ef7958337a57644d9d3fe59702dd4 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 19 Jan 2021 15:26:44 +0800 Subject: [PATCH] TD-1207 --- src/dnode/src/dnodeSystem.c | 3 +++ src/os/inc/osSignal.h | 2 +- src/os/src/windows/wSignal.c | 13 ++++++++++--- tests/script/sh/deploy.bat | 2 +- tests/script/sh/exec.bat | 9 ++++++++- tests/script/wtest.bat | 2 +- 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/dnode/src/dnodeSystem.c b/src/dnode/src/dnodeSystem.c index 3a50eca9e6..dcbf249a51 100644 --- a/src/dnode/src/dnodeSystem.c +++ b/src/dnode/src/dnodeSystem.c @@ -145,6 +145,8 @@ int32_t main(int32_t argc, char *argv[]) { syslog(LOG_INFO, "Shut down TDengine service successfully"); dInfo("TDengine is shut down!"); closelog(); + + tsem_post(&exitSem); return EXIT_SUCCESS; } @@ -170,4 +172,5 @@ static void sigintHandler(int32_t signum) { // inform main thread to exit tsem_post(&exitSem); + tsem_wait(&exitSem); } \ No newline at end of file diff --git a/src/os/inc/osSignal.h b/src/os/inc/osSignal.h index 57582a8a28..8016c49ba8 100644 --- a/src/os/inc/osSignal.h +++ b/src/os/inc/osSignal.h @@ -29,7 +29,7 @@ extern "C" { #endif #ifndef SIGHUP - #define SIGHUP 1234 + #define SIGHUP 1230 #endif #ifndef SIGCHLD diff --git a/src/os/src/windows/wSignal.c b/src/os/src/windows/wSignal.c index 8a3c2cfbd4..3988f0c6e1 100644 --- a/src/os/src/windows/wSignal.c +++ b/src/os/src/windows/wSignal.c @@ -16,18 +16,25 @@ #define _DEFAULT_SOURCE #include "os.h" #include +#include void taosSetSignal(int32_t signum, FSignalHandler sigfp) { if (signum == SIGUSR1) return; - signal(signum, sigfp); + + // SIGHUP doesn't exist in windows, we handle it in the way of ctrlhandler + if (signum == SIGHUP) { + SetConsoleCtrlHandler((PHANDLER_ROUTINE)sigfp, TRUE); + } else { + signal(signum, sigfp); + } } void taosIgnSignal(int32_t signum) { - if (signum == SIGUSR1) return; + if (signum == SIGUSR1 || signum == SIGHUP) return; signal(signum, SIG_IGN); } void taosDflSignal(int32_t signum) { - if (signum == SIGUSR1) return; + if (signum == SIGUSR1 || signum == SIGHUP) return; signal(signum, SIG_DFL); } diff --git a/tests/script/sh/deploy.bat b/tests/script/sh/deploy.bat index 0b419b1e9b..7a81761e5b 100644 --- a/tests/script/sh/deploy.bat +++ b/tests/script/sh/deploy.bat @@ -54,7 +54,7 @@ if %NODE% == 6 set NODE=7600 if %NODE% == 7 set NODE=7700 if %NODE% == 8 set NODE=7800 -set "fqdn=" +rem set "fqdn=" for /f "skip=1" %%A in ( 'wmic computersystem get caption' ) do if not defined fqdn set "fqdn=%%A" diff --git a/tests/script/sh/exec.bat b/tests/script/sh/exec.bat index 47b7910210..9ad6667644 100644 --- a/tests/script/sh/exec.bat +++ b/tests/script/sh/exec.bat @@ -37,5 +37,12 @@ if %EXEC_OPTON% == start ( if %EXEC_OPTON% == stop ( rem echo wmic process where "name='taosd.exe' and CommandLine like '%%%NODE_NAME%%%'" list INSTANCE - wmic process where "name='taosd.exe' and CommandLine like '%%%NODE_NAME%%%'" call terminate > NUL 2>&1 + rem wmic process where "name='taosd.exe' and CommandLine like '%%%NODE_NAME%%%'" call terminate > NUL 2>&1 + + for /f "tokens=1 skip=1" %%A in ( + 'wmic process where "name='taosd.exe'" get processId ' + ) do ( + rem echo taskkill /IM %%A + taskkill /IM %%A > NUL 2>&1 + ) ) diff --git a/tests/script/wtest.bat b/tests/script/wtest.bat index a89c1df67a..0b5cdda527 100644 --- a/tests/script/wtest.bat +++ b/tests/script/wtest.bat @@ -33,7 +33,7 @@ if exist %LOG_DIR% rmdir /s/q %LOG_DIR% if not exist %CFG_DIR% mkdir %CFG_DIR% if not exist %LOG_DIR% mkdir %LOG_DIR% -set "fqdn=" +rem set "fqdn=" for /f "skip=1" %%A in ( 'wmic computersystem get caption' ) do if not defined fqdn set "fqdn=%%A" -- GitLab