Skip to content

Commit

Permalink
Revert "Handle CTRL-C better on MacOS"
Browse files Browse the repository at this point in the history
This reverts commit b0b4613.
  • Loading branch information
jart committed Nov 22, 2024
1 parent b0b4613 commit ca334a1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion llama.cpp/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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 (;;) {
}
}
Expand Down

0 comments on commit ca334a1

Please sign in to comment.