Skip to content

Distribute and run LLMs with a single file.

Revert "Handle CTRL-C better on MacOS"

Justine Tunneyca334a1ee8ef
diff --git a/llama.cpp/main/main.cpp b/llama.cpp/main/main.cpp
index 92609978..12fbca74 100644
--- a/llama.cpp/main/main.cpp
+++ b/llama.cpp/main/main.cpp
@@ -37,6 +37,9 @@ static std::vector<llama_token> * g_output_tokens;
static bool is_interacting = false;
static bool need_insert_eot = false;
+extern "C" int nsync_futex_wake_(int *, int, char);
+extern "C" int nsync_futex_wait_(int *, int, char, const struct timespec *);
+
static bool file_exists(const std::string & path) {
std::ifstream f(path.c_str());
return f.good();
@@ -97,7 +100,7 @@ static int is_killed;
static void *safe_sigint_handler(void *arg) {
while (!is_killed)
- usleep(50 * 1000);
+ nsync_futex_wait_(&is_killed, 0, 0, 0);
console::cleanup();
printf("\n");
llama_print_timings(*g_ctx);
@@ -122,6 +125,7 @@ static void sigint_handler(int signo) {
is_interacting = true;
} else {
is_killed = true;
+ nsync_futex_wake_(&is_killed, 1, 0);
for (;;) {
}
}