summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorGeorgi Gerganov <ggerganov@gmail.com>2024-02-11 15:35:50 +0200
committerGeorgi Gerganov <ggerganov@gmail.com>2024-02-11 15:35:50 +0200
commit85910c5b30f6e268321be8df044f5528a6efac52 (patch)
tree38c7d28b59f1b7740824ac83a2b46836a36237f2 /examples
parent139b62a839825ef20084ed75ed624db7a5ad554a (diff)
main : ctrl+C print timing in non-interactive mode (#3873)
Diffstat (limited to 'examples')
-rw-r--r--examples/main/main.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/examples/main/main.cpp b/examples/main/main.cpp
index 0ed4d79f..e8ab8cba 100644
--- a/examples/main/main.cpp
+++ b/examples/main/main.cpp
@@ -98,7 +98,7 @@ static void write_logfile(
#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__)) || defined (_WIN32)
static void sigint_handler(int signo) {
if (signo == SIGINT) {
- if (!is_interacting) {
+ if (!is_interacting && g_params->interactive) {
is_interacting = true;
} else {
console::cleanup();
@@ -392,7 +392,8 @@ int main(int argc, char ** argv) {
LOG_TEE("\n");
}
- if (params.interactive) {
+ // ctrl+C handling
+ {
#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))
struct sigaction sigint_action;
sigint_action.sa_handler = sigint_handler;
@@ -405,7 +406,9 @@ int main(int argc, char ** argv) {
};
SetConsoleCtrlHandler(reinterpret_cast<PHANDLER_ROUTINE>(console_ctrl_handler), true);
#endif
+ }
+ if (params.interactive) {
LOG_TEE("%s: interactive mode on.\n", __func__);
if (!params.antiprompt.empty()) {