Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include <sysexits.h>
#elif _WIN32
#include <csignal>
#include <cstdio>
#include <io.h>

#include <ntstatus.h>
#include <winsock2.h>
Expand Down Expand Up @@ -140,7 +142,17 @@ static void onTerminate(int status) {
}

static void onIllegal(int status) {
Server::instance().setShutdownRequest(2);
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 __attribute__((unused)) = write(STDERR_FILENO, msg, sizeof(msg) - 1);
#elif _WIN32
int ret = _write(_fileno(stderr), msg, sizeof(msg) - 1);
(void)ret;
#endif
// 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.
_exit(128 + SIGILL);
}

#ifdef __linux__
Expand Down Expand Up @@ -524,9 +536,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;
Expand Down