diff options
Diffstat (limited to 'cpp/src/slice2html/Main.cpp')
-rw-r--r-- | cpp/src/slice2html/Main.cpp | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/cpp/src/slice2html/Main.cpp b/cpp/src/slice2html/Main.cpp index d7a3b1911bc..fb5fcb9a2d3 100644 --- a/cpp/src/slice2html/Main.cpp +++ b/cpp/src/slice2html/Main.cpp @@ -8,8 +8,9 @@ // ********************************************************************** #include <IceUtil/Options.h> +#include <IceUtil/CtrlCHandler.h> +#include <IceUtil/StaticMutex.h> #include <Slice/Preprocessor.h> -#include <Slice/SignalHandler.h> #include <Gen.h> #include <stdlib.h> @@ -17,6 +18,17 @@ using namespace std; using namespace Slice; using namespace IceUtil; +static IceUtil::StaticMutex _mutex = ICE_STATIC_MUTEX_INITIALIZER; +static bool _interrupted = false; + +void +interruptedCallback(int signal) +{ + IceUtil::StaticMutex::Lock lock(_mutex); + + _interrupted = true; +} + void usage(const char* n) { @@ -173,7 +185,8 @@ main(int argc, char* argv[]) int status = EXIT_SUCCESS; - SignalHandler sigHandler; + IceUtil::CtrlCHandler ctrlCHandler; + ctrlCHandler.setCallback(interruptedCallback); for(vector<string>::size_type idx = 0; idx < args.size(); ++idx) { @@ -207,6 +220,15 @@ main(int argc, char* argv[]) p->destroy(); return EXIT_FAILURE; } + + { + IceUtil::StaticMutex::Lock lock(_mutex); + + if(_interrupted) + { + return EXIT_FAILURE; + } + } } if(status == EXIT_SUCCESS && !preprocess) @@ -230,5 +252,14 @@ main(int argc, char* argv[]) p->destroy(); + { + IceUtil::StaticMutex::Lock lock(_mutex); + + if(_interrupted) + { + return EXIT_FAILURE; + } + } + return status; } |