Skip to content

Commit db455e7

Browse files
ggerganovhodlen
authored andcommitted
main : ctrl+C print timing in non-interactive mode (ggml-org#3873)
1 parent 33cd8c5 commit db455e7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

examples/main/main.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static void write_logfile(
9898
#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__)) || defined (_WIN32)
9999
static void sigint_handler(int signo) {
100100
if (signo == SIGINT) {
101-
if (!is_interacting) {
101+
if (!is_interacting && g_params->interactive) {
102102
is_interacting = true;
103103
} else {
104104
console::cleanup();
@@ -392,7 +392,8 @@ int main(int argc, char ** argv) {
392392
LOG_TEE("\n");
393393
}
394394

395-
if (params.interactive) {
395+
// ctrl+C handling
396+
{
396397
#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))
397398
struct sigaction sigint_action;
398399
sigint_action.sa_handler = sigint_handler;
@@ -405,7 +406,9 @@ int main(int argc, char ** argv) {
405406
};
406407
SetConsoleCtrlHandler(reinterpret_cast<PHANDLER_ROUTINE>(console_ctrl_handler), true);
407408
#endif
409+
}
408410

411+
if (params.interactive) {
409412
LOG_TEE("%s: interactive mode on.\n", __func__);
410413

411414
if (!params.antiprompt.empty()) {

0 commit comments

Comments
 (0)