diff --git a/src/server.cpp b/src/server.cpp index 144ca3ec35..4a89a304b9 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -37,6 +37,8 @@ #include #elif _WIN32 #include +#include +#include #include #include @@ -140,7 +142,18 @@ static void onTerminate(int status) { } static void onIllegal(int status) { - Server::instance().setShutdownRequest(2); + (void)status; + const char msg[] = "SIGILL received: illegal instruction. This may indicate an unsupported CPU or device or an internal error. Terminating.\n"; +#ifdef __linux__ + ssize_t ret = write(STDERR_FILENO, msg, sizeof(msg) - 1); +#elif _WIN32 + int ret = _write(_fileno(stderr), msg, sizeof(msg) - 1); +#endif + (void)ret; + // Exit code 128+N is the standard shell convention for signal-terminated + // processes (bash, dash, Docker, Kubernetes all follow this). + // For SIGILL(4) this gives exit code 132. + std::_Exit(128 + SIGILL); } #ifdef __linux__ @@ -524,9 +537,6 @@ int Server::startServerFromSettings(ServerSettingsImpl& serverSettings, ModelsSe (serverSettings.serverMode == HF_PULL_AND_START_MODE || serverSettings.serverMode == SERVING_MODELS_MODE)) { std::this_thread::sleep_for(std::chrono::milliseconds(200)); } - if (getShutdownStatus() == 2) { - SPDLOG_ERROR("Illegal operation. OVMS started on unsupported device"); - } } catch (const std::exception& e) { SPDLOG_ERROR("Exception; {}", e.what()); result = OVMS_EX_FAILURE;