From: Arnaud Giersch Date: Fri, 20 May 2011 15:23:48 +0000 (+0200) Subject: Use sig_atomic_t for opt::exit_request. X-Git-Tag: v0.1~62^2~17 X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/commitdiff_plain/1017c5419ee314344cc11741052e51eca59b846e?ds=sidebyside;hp=--cc Use sig_atomic_t for opt::exit_request. --- 1017c5419ee314344cc11741052e51eca59b846e diff --git a/main.cpp b/main.cpp index b924349..bce9749 100644 --- a/main.cpp +++ b/main.cpp @@ -1,7 +1,7 @@ #include +#include #include // strchr #include -#include #include #include #include @@ -141,7 +141,7 @@ static void signal_handler(int /*sig*/) XBT_CRITICAL(">>>>>>>>>>" " caught CTRL-C: global exit requested " "<<<<<<<<<<"); - opt::exit_request = true; + opt::exit_request = 1; } else { XBT_CRITICAL(">>>>>>>>>>" " caught CTRL-C for the 2nd time: exit immediately " diff --git a/options.cpp b/options.cpp index 3e0f92d..373f4c6 100644 --- a/options.cpp +++ b/options.cpp @@ -39,7 +39,7 @@ namespace opt { // Simulation parameters int log_rate = 1; - bool exit_request = false; + volatile sig_atomic_t exit_request = 0; // Platform and deployment std::string platform_file; diff --git a/options.h b/options.h index 604d178..35334a5 100644 --- a/options.h +++ b/options.h @@ -1,6 +1,7 @@ #ifndef OPTIONS_H #define OPTIONS_H +#include // sig_atomic_t #include #include "cost_func.h" #include "named_object_list.h" @@ -23,7 +24,7 @@ namespace opt { // Simulation parameters extern int log_rate; - extern bool exit_request; + extern volatile sig_atomic_t exit_request; // Platform and deployment extern std::string platform_file;