fix: osSys
This commit is contained in:
parent
ae9eaf9d1a
commit
045a041844
|
@ -31,7 +31,7 @@ void WINAPI windowsServiceCtrlHandle(DWORD request) {
|
||||||
ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING;
|
ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING;
|
||||||
if (!SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) {
|
if (!SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) {
|
||||||
DWORD nError = GetLastError();
|
DWORD nError = GetLastError();
|
||||||
printf("failed to send stopped status to windows service: %d", nError);
|
fprintf(stderr, "failed to send stopped status to windows service: %d", nError);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -50,19 +50,19 @@ void WINAPI mainWindowsService(int argc, char** argv) {
|
||||||
hServiceStatusHandle = RegisterServiceCtrlHandler("taosd", &windowsServiceCtrlHandle);
|
hServiceStatusHandle = RegisterServiceCtrlHandler("taosd", &windowsServiceCtrlHandle);
|
||||||
if (hServiceStatusHandle == 0) {
|
if (hServiceStatusHandle == 0) {
|
||||||
DWORD nError = GetLastError();
|
DWORD nError = GetLastError();
|
||||||
printf("failed to register windows service ctrl handler: %d", nError);
|
fprintf(stderr, "failed to register windows service ctrl handler: %d", nError);
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceStatus.dwCurrentState = SERVICE_RUNNING;
|
ServiceStatus.dwCurrentState = SERVICE_RUNNING;
|
||||||
if (SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) {
|
if (SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) {
|
||||||
DWORD nError = GetLastError();
|
DWORD nError = GetLastError();
|
||||||
printf("failed to send running status to windows service: %d", nError);
|
fprintf(stderr, "failed to send running status to windows service: %d", nError);
|
||||||
}
|
}
|
||||||
if (mainWindowsFunc != NULL) mainWindowsFunc(argc, argv);
|
if (mainWindowsFunc != NULL) mainWindowsFunc(argc, argv);
|
||||||
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
|
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
|
||||||
if (!SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) {
|
if (!SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) {
|
||||||
DWORD nError = GetLastError();
|
DWORD nError = GetLastError();
|
||||||
printf("failed to send stopped status to windows service: %d", nError);
|
fprintf(stderr, "failed to send stopped status to windows service: %d", nError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void stratWindowsService(MainWindows mainWindows) {
|
void stratWindowsService(MainWindows mainWindows) {
|
||||||
|
@ -140,17 +140,27 @@ void taosCloseDll(void* handle) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int taosSetConsoleEcho(bool on) {
|
int32_t taosSetConsoleEcho(bool on) {
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
|
HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
|
if (hStdin == INVALID_HANDLE_VALUE) {
|
||||||
|
terrno = TAOS_SYSTEM_WINAPI_ERROR(GetLastError());
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
DWORD mode = 0;
|
DWORD mode = 0;
|
||||||
GetConsoleMode(hStdin, &mode);
|
if(!GetConsoleMode(hStdin, &mode)){
|
||||||
|
terrno = TAOS_SYSTEM_WINAPI_ERROR(GetLastError());
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
if (on) {
|
if (on) {
|
||||||
mode |= ENABLE_ECHO_INPUT;
|
mode |= ENABLE_ECHO_INPUT;
|
||||||
} else {
|
} else {
|
||||||
mode &= ~ENABLE_ECHO_INPUT;
|
mode &= ~ENABLE_ECHO_INPUT;
|
||||||
}
|
}
|
||||||
SetConsoleMode(hStdin, mode);
|
if(!SetConsoleMode(hStdin, mode)) {
|
||||||
|
terrno = TAOS_SYSTEM_WINAPI_ERROR(GetLastError());
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in New Issue