From: Georgi Gerganov Date: Fri, 20 Sep 2024 08:46:56 +0000 (+0300) Subject: examples : flush log upon ctrl+c (#9559) X-Git-Tag: upstream/0.0.4488~698 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=d39e26741f9f02340651dbc640c9776e1a1128ef;p=pkg%2Fggml%2Fsources%2Fllama.cpp examples : flush log upon ctrl+c (#9559) --- diff --git a/examples/infill/infill.cpp b/examples/infill/infill.cpp index b77b876c..35607276 100644 --- a/examples/infill/infill.cpp +++ b/examples/infill/infill.cpp @@ -97,6 +97,11 @@ static void sigint_handler(int signo) { LOG("\n"); gpt_perf_print(*g_ctx, *g_smpl); write_logfile(*g_ctx, *g_params, *g_model, *g_input_tokens, g_output_ss->str(), *g_output_tokens); + + // make sure all logs are flushed + LOG("Interrupted by user\n"); + gpt_log_pause(gpt_log_main()); + _exit(130); } } diff --git a/examples/main/main.cpp b/examples/main/main.cpp index 91fea932..c3041f1f 100644 --- a/examples/main/main.cpp +++ b/examples/main/main.cpp @@ -116,6 +116,11 @@ static void sigint_handler(int signo) { LOG("\n"); gpt_perf_print(*g_ctx, *g_smpl); write_logfile(*g_ctx, *g_params, *g_model, *g_input_tokens, g_output_ss->str(), *g_output_tokens); + + // make sure all logs are flushed + LOG("Interrupted by user\n"); + gpt_log_pause(gpt_log_main()); + _exit(130); } }