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/slice2cpp/Main.cpp | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'cpp/src/slice2cpp/Main.cpp') diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp index 4ead491dd22..f23c45a9739 100644 --- a/cpp/src/slice2cpp/Main.cpp +++ b/cpp/src/slice2cpp/Main.cpp @@ -9,13 +9,24 @@ #include #include +#include #include -#include #include using namespace std; using namespace Slice; +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) { @@ -150,12 +161,11 @@ main(int argc, char* argv[]) int status = EXIT_SUCCESS; + IceUtil::CtrlCHandler ctrlCHandler; + ctrlCHandler.setCallback(interruptedCallback); + for(i = args.begin(); i != args.end(); ++i) { - SignalHandler::clearCleanupFileList(); - IceUtil::CtrlCHandler ctrlCHandler; - ctrlCHandler.setCallback(SignalHandler::removeFilesOnInterrupt); - if(depend) { Preprocessor icecpp(argv[0], *i, cppArgs); @@ -216,6 +226,15 @@ main(int argc, char* argv[]) u->destroy(); } } + + { + IceUtil::StaticMutex::Lock lock(_mutex); + + if(_interrupted) + { + return EXIT_FAILURE; + } + } } return status; -- cgit v1.2.3