summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cpp/Main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/slice2cpp/Main.cpp')
-rw-r--r--cpp/src/slice2cpp/Main.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp
index 0fef7634add..f23c45a9739 100644
--- a/cpp/src/slice2cpp/Main.cpp
+++ b/cpp/src/slice2cpp/Main.cpp
@@ -8,13 +8,25 @@
// **********************************************************************
#include <IceUtil/Options.h>
+#include <IceUtil/CtrlCHandler.h>
+#include <IceUtil/StaticMutex.h>
#include <Slice/Preprocessor.h>
-#include <Slice/SignalHandler.h>
#include <Gen.h>
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)
{
@@ -149,10 +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 sigHandler;
-
if(depend)
{
Preprocessor icecpp(argv[0], *i, cppArgs);
@@ -213,6 +226,15 @@ main(int argc, char* argv[])
u->destroy();
}
}
+
+ {
+ IceUtil::StaticMutex::Lock lock(_mutex);
+
+ if(_interrupted)
+ {
+ return EXIT_FAILURE;
+ }
+ }
}
return status;