Skip to content

Commit d39e267

Browse files
authored
examples : flush log upon ctrl+c (#9559)
1 parent 722ec1e commit d39e267

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

examples/infill/infill.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ static void sigint_handler(int signo) {
9797
LOG("\n");
9898
gpt_perf_print(*g_ctx, *g_smpl);
9999
write_logfile(*g_ctx, *g_params, *g_model, *g_input_tokens, g_output_ss->str(), *g_output_tokens);
100+
101+
// make sure all logs are flushed
102+
LOG("Interrupted by user\n");
103+
gpt_log_pause(gpt_log_main());
104+
100105
_exit(130);
101106
}
102107
}

examples/main/main.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ static void sigint_handler(int signo) {
116116
LOG("\n");
117117
gpt_perf_print(*g_ctx, *g_smpl);
118118
write_logfile(*g_ctx, *g_params, *g_model, *g_input_tokens, g_output_ss->str(), *g_output_tokens);
119+
120+
// make sure all logs are flushed
121+
LOG("Interrupted by user\n");
122+
gpt_log_pause(gpt_log_main());
123+
119124
_exit(130);
120125
}
121126
}

0 commit comments

Comments
 (0)