From 1017c5419ee314344cc11741052e51eca59b846e Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 20 May 2011 17:23:48 +0200 Subject: [PATCH 1/1] Use sig_atomic_t for opt::exit_request. --- main.cpp | 4 ++-- options.cpp | 2 +- options.h | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) 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; -- 2.39.5