summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cpp/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/slice2cpp/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/slice2cpp/Main.cpp')
-rw-r--r--cpp/src/slice2cpp/Main.cpp29
1 files changed, 24 insertions, 5 deletions
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 <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)
{
@@ -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;