summaryrefslogtreecommitdiff
path: root/cpp/src/slice2html/Main.cpp
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2008-11-20 10:22:31 -0330
committerDwayne Boone <dwayne@zeroc.com>2008-11-20 10:22:31 -0330
commitaa4f3340e17e227a26659a75a8f60d24c2dd5323 (patch)
treec118d1d651d48f236c911d25f8a3f3b34320783f /cpp/src/slice2html/Main.cpp
parentBug 3550 - slice compiler not able to open tmp file on Vista (diff)
downloadice-aa4f3340e17e227a26659a75a8f60d24c2dd5323.tar.bz2
ice-aa4f3340e17e227a26659a75a8f60d24c2dd5323.tar.xz
ice-aa4f3340e17e227a26659a75a8f60d24c2dd5323.zip
Refactored CtrlCHandler usage in slice compilers
Diffstat (limited to 'cpp/src/slice2html/Main.cpp')
-rw-r--r--cpp/src/slice2html/Main.cpp33
1 files changed, 31 insertions, 2 deletions
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 <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>
@@ -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<string>::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;
}