From 6ff7b50a7de5ad329b185bfaf5b44fa54ed6c91b Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Mon, 22 Feb 2016 12:03:58 -0500 Subject: [PATCH] use atomic variable for the control-c flag. --- command.cpp | 3 ++- mpw-shell.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/command.cpp b/command.cpp index 1357a3f..64d120b 100644 --- a/command.cpp +++ b/command.cpp @@ -18,8 +18,9 @@ #include #include #include +#include -extern volatile int control_c; +extern std::atomic control_c; namespace fs = filesystem; extern fs::path mpw_path(); diff --git a/mpw-shell.cpp b/mpw-shell.cpp index 1ffe24b..574db95 100644 --- a/mpw-shell.cpp +++ b/mpw-shell.cpp @@ -29,6 +29,7 @@ #include #include #include +#include namespace fs = filesystem; @@ -168,13 +169,13 @@ int read_make(phase1 &p1, phase2 &p2, Environment &env, const std::vector control_c{0}; void control_c_handler(int signal, siginfo_t *sinfo, void *context) { // libedit gobbles up the first control-C and doesn't return until the second. - // GNU's readline may return no the first. + // GNU's readline may return on the first. if (control_c > 3) abort(); - control_c++; + ++control_c; //fprintf(stderr, "interrupt!\n"); }