From: Arnaud Giersch Date: Mon, 16 May 2011 16:03:47 +0000 (+0200) Subject: Quit immediately on 2nd Ctrl-C. X-Git-Tag: v0.1~62^2~20 X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/commitdiff_plain/b1ce579c3259c3539aaa37738c08092de6f51a17?hp=60717051546e6826cec4124e3414bba65ad75d0c Quit immediately on 2nd Ctrl-C. --- 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); }