Skip to content

Distribute and run LLMs with a single file.

Prevent rare double printing of stats

Justine Tunney8ba17eaedde9
diff --git a/llama.cpp/main/main.cpp b/llama.cpp/main/main.cpp
index 81af6bc1..4c605992 100644
--- a/llama.cpp/main/main.cpp
+++ b/llama.cpp/main/main.cpp
@@ -480,11 +480,11 @@ int main(int argc, char ** argv) {
LOG_TEE("\n");
}
- struct sigaction sa;
+ struct sigaction sa, oldsa;
sa.sa_handler = sigint_handler;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
- sigaction(SIGINT, &sa, NULL);
+ sigaction(SIGINT, &sa, &oldsa);
if (params.interactive) {
LOG_TEE("%s: interactive mode on.\n", __func__);
@@ -1013,6 +1013,8 @@ int main(int argc, char ** argv) {
}
}
+ sigaction(SIGINT, &oldsa, 0);
+
// [jart] ensure trailing newline
printf("\n");