From b1ce579c3259c3539aaa37738c08092de6f51a17 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Mon, 16 May 2011 18:03:47 +0200 Subject: [PATCH 1/1] Quit immediately on 2nd Ctrl-C. --- main.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index a88378d..b924349 100644 --- a/main.cpp +++ b/main.cpp @@ -38,7 +38,8 @@ namespace { EXIT_FAILURE_INIT = 0x02, // failed to initialize simulator EXIT_FAILURE_SIMU = 0x04, // simulation failed EXIT_FAILURE_CLEAN = 0x08, // error at cleanup - EXIT_FAILURE_OTHER = 0x10, // other error + EXIT_FAILURE_INTR = 0x10, // interrupted by user + EXIT_FAILURE_OTHER = 0x20, // other error }; // Cannot be globally initialized... @@ -141,6 +142,11 @@ static void signal_handler(int /*sig*/) " caught CTRL-C: global exit requested " "<<<<<<<<<<"); opt::exit_request = true; + } else { + XBT_CRITICAL(">>>>>>>>>>" + " caught CTRL-C for the 2nd time: exit immediately " + "<<<<<<<<<<"); + exit(EXIT_FAILURE_INTR); } } @@ -150,7 +156,7 @@ static void install_signal_handler() action.sa_handler = signal_handler; sigemptyset(&action.sa_mask); action.sa_flags = SA_RESTART; - if (sigaction (SIGINT, &action, NULL) == -1) { + if (sigaction(SIGINT, &action, NULL) == -1) { std::cerr << "sigaction: " << strerror(errno) << "\n"; exit(EXIT_FAILURE_OTHER); } -- 2.39.5