From aa4f3340e17e227a26659a75a8f60d24c2dd5323 Mon Sep 17 00:00:00 2001 From: Dwayne Boone Date: Thu, 20 Nov 2008 10:22:31 -0330 Subject: Refactored CtrlCHandler usage in slice compilers --- cpp/src/slice2html/Main.cpp | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'cpp/src/slice2html/Main.cpp') diff --git a/cpp/src/slice2html/Main.cpp b/cpp/src/slice2html/Main.cpp index b63082571bb..fb5fcb9a2d3 100644 --- a/cpp/src/slice2html/Main.cpp +++ b/cpp/src/slice2html/Main.cpp @@ -9,8 +9,8 @@ #include #include +#include #include -#include #include #include @@ -18,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) { @@ -175,7 +186,7 @@ main(int argc, char* argv[]) int status = EXIT_SUCCESS; IceUtil::CtrlCHandler ctrlCHandler; - ctrlCHandler.setCallback(SignalHandler::removeFilesOnInterrupt); + ctrlCHandler.setCallback(interruptedCallback); for(vector::size_type idx = 0; idx < args.size(); ++idx) { @@ -209,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) @@ -232,5 +252,14 @@ main(int argc, char* argv[]) p->destroy(); + { + IceUtil::StaticMutex::Lock lock(_mutex); + + if(_interrupted) + { + return EXIT_FAILURE; + } + } + return status; } -- cgit v1.2.3