Merge remote-tracking branch 'sandbox/190/work' into feature/ctrlc-cancel
This commit is contained in:
+23
-1
@@ -29,16 +29,38 @@
|
||||
#include <filesystem>
|
||||
#include <random>
|
||||
#include <iomanip>
|
||||
#ifndef _WIN32
|
||||
#include <signal.h>
|
||||
#else
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
std::atomic<bool> ctrlc_request;
|
||||
|
||||
#if defined(_WIN32)
|
||||
BOOL WINAPI console_handler(DWORD ctrl_type) {
|
||||
if (ctrl_type == CTRL_C_EVENT) {
|
||||
ctrlc_request = true;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void setup_signal_handler() {
|
||||
SetConsoleCtrlHandler(console_handler, TRUE);
|
||||
}
|
||||
#else
|
||||
void signalHandler(int signal) {
|
||||
if (signal == SIGINT) {
|
||||
ctrlc_request = true;
|
||||
}
|
||||
}
|
||||
|
||||
void setup_signal_handler() {
|
||||
signal(SIGINT, signalHandler);
|
||||
}
|
||||
#endif
|
||||
|
||||
static const std::vector<AgentProfile> profiles = {
|
||||
#if !defined(_WIN32)
|
||||
{
|
||||
@@ -106,7 +128,7 @@ static HarnessState read_harness_state_or_exit(const char* file_path) {
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
signal(SIGINT, signalHandler);
|
||||
setup_signal_handler();
|
||||
|
||||
OllamaConfig cfg;
|
||||
if (const char* m = std::getenv("OLLAMA_MODEL")) cfg.model = m;
|
||||
|
||||
Reference in New Issue
Block a user