]> AND Private Git Repository - loba.git/commitdiff
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
Quit immediately on 2nd Ctrl-C.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Mon, 16 May 2011 16:03:47 +0000 (18:03 +0200)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Mon, 16 May 2011 16:03:47 +0000 (18:03 +0200)
main.cpp

index a88378daa584a7321a48f71e4c7f0ad8b812dfe1..b924349cb325121aa3b7e67c830529ec7897fafd 100644 (file)
--- 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_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...
     };
 
     // Cannot be globally initialized...
@@ -141,6 +142,11 @@ static void signal_handler(int /*sig*/)
                      " caught CTRL-C: global exit requested "
                      "<<<<<<<<<<");
         opt::exit_request = true;
                      " 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;
     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);
     }
         std::cerr << "sigaction: " << strerror(errno) << "\n";
         exit(EXIT_FAILURE_OTHER);
     }