diff --git a/cmake/cmake.options b/cmake/cmake.options index 5d99b2214a36d6a6af3234cd6582e9915c89366b..51d6f530483a9571f24c0ca1ac7e31508c8ab2bf 100644 --- a/cmake/cmake.options +++ b/cmake/cmake.options @@ -51,6 +51,13 @@ IF(${TD_WINDOWS}) "If build unit tests using googletest" ON ) + + option( + TDENGINE_3 + "TDengine 3.x" + ON + ) + ELSEIF (TD_DARWIN_64) add_definitions(-DCOMPILER_SUPPORTS_CXX13) option( diff --git a/include/os/osSignal.h b/include/os/osSignal.h index e22c43684cda403d82eabd670b6828f2fb99bc85..12f4f2ed0fb9ea2511a876772dd27f8f5b5a3379 100644 --- a/include/os/osSignal.h +++ b/include/os/osSignal.h @@ -44,7 +44,11 @@ extern "C" { #define SIGBREAK 1234 #endif +#ifdef WINDOWS +typedef BOOL (*FSignalHandler)(DWORD fdwCtrlType); +#else typedef void (*FSignalHandler)(int32_t signum, void *sigInfo, void *context); +#endif void taosSetSignal(int32_t signum, FSignalHandler sigfp); void taosIgnSignal(int32_t signum); void taosDflSignal(int32_t signum); diff --git a/include/os/osSystem.h b/include/os/osSystem.h index 581e688ccb1adedf75552c6f21a9828eb01f9d99..6770be6e461c45c55238e4f9b3f059cfbf81487f 100644 --- a/include/os/osSystem.h +++ b/include/os/osSystem.h @@ -29,9 +29,6 @@ extern "C" { #define tcgetattr TCGETATTR_FUNC_TAOS_FORBID #endif -#define TAOS_CONSOLE_PROMPT_HEADER "taos> " -#define TAOS_CONSOLE_PROMPT_CONTINUE " -> " - typedef struct TdCmd *TdCmdPtr; TdCmdPtr taosOpenCmd(const char* cmd); diff --git a/source/os/src/osSystem.c b/source/os/src/osSystem.c index 9c66ac1df8ba42526403eb64e66e1f8cc6ef696a..ad7fa571828b0ec682c1238a20bf5dcf0b8563dc 100644 --- a/source/os/src/osSystem.c +++ b/source/os/src/osSystem.c @@ -18,10 +18,6 @@ #include "os.h" #if defined(WINDOWS) -BOOL WINAPI CtrlHandler(DWORD fdwCtrlType) { - printf("\n" TAOS_CONSOLE_PROMPT_HEADER); - return TRUE; -} #elif defined(_TD_DARWIN_64) #else #include @@ -128,7 +124,6 @@ int taosSetConsoleEcho(bool on) { void taosSetTerminalMode() { #if defined(WINDOWS) - SetConsoleCtrlHandler(CtrlHandler, TRUE); #else struct termios newtio; @@ -179,7 +174,6 @@ int32_t taosGetOldTerminalMode() { void taosResetTerminalMode() { #if defined(WINDOWS) - SetConsoleCtrlHandler(CtrlHandler, FALSE); #else if (tcsetattr(0, TCSANOW, &oldtio) != 0) { fprintf(stderr, "Fail to reset the terminal properties!\n"); diff --git a/tools/shell/src/shellArguments.c b/tools/shell/src/shellArguments.c index cdbdc0de604d6359ce73d834ac84b7b7c5482395..466aa523903b6d8ae3270a6cfd7cae0e39d69257 100644 --- a/tools/shell/src/shellArguments.c +++ b/tools/shell/src/shellArguments.c @@ -19,6 +19,9 @@ #include "shellInt.h" +#define TAOS_CONSOLE_PROMPT_HEADER "taos> " +#define TAOS_CONSOLE_PROMPT_CONTINUE " -> " + #define SHELL_HOST "The auth string to use when connecting to the server." #define SHELL_PORT "The TCP/IP port number to use for the connection." #define SHELL_USER "The user name to use when connecting to the server." diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index eefb0aa8b28f75a4d57a34b176d0ecb1a1d9bb2f..56bc1ed6cc98468d87516236ef08b99aaa653936 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -41,7 +41,7 @@ static void shellPrintError(TAOS_RES *tres, int64_t st); static bool shellIsCommentLine(char *line); static void shellSourceFile(const char *file); static void shellGetGrantInfo(); -static void shellQueryInterruptHandler(int32_t signum, void *sigInfo, void *context); + static void shellCleanup(void *arg); static void *shellCancelHandler(void *arg); static void *shellThreadLoop(void *arg); @@ -919,11 +919,14 @@ void shellGetGrantInfo() { fprintf(stdout, "\r\n"); } -void shellQueryInterruptHandler(int32_t signum, void *sigInfo, void *context) { tsem_post(&shell.cancelSem); } - -void shellSigintHandler(int32_t signum, void *sigInfo, void *context) { - // do nothing +#ifdef WINDOWS +BOOL shellQueryInterruptHandler(DWORD fdwCtrlType) { + tsem_post(&shell.cancelSem); + return TRUE; } +#else +void shellQueryInterruptHandler(int32_t signum, void *sigInfo, void *context) { tsem_post(&shell.cancelSem); } +#endif void shellCleanup(void *arg) { taosResetTerminalMode(); } @@ -934,11 +937,10 @@ void *shellCancelHandler(void *arg) { taosMsleep(10); continue; } - - taosResetTerminalMode(); - printf("\r\nReceive SIGTERM or other signal, quit shell.\r\n"); - shellWriteHistory(); - shellExit(); + taos_kill_query(shell.conn); + #ifdef WINDOWS + printf("\n%s", shell.info.promptHeader); + #endif } return NULL; @@ -1022,7 +1024,7 @@ int32_t shellExecute() { taosSetSignal(SIGHUP, shellQueryInterruptHandler); taosSetSignal(SIGABRT, shellQueryInterruptHandler); - taosSetSignal(SIGINT, shellSigintHandler); + taosSetSignal(SIGINT, shellQueryInterruptHandler); shellGetGrantInfo();