summaryrefslogtreecommitdiff
path: root/cpp/src/slice2docbook/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/slice2docbook/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/slice2docbook/Main.cpp')
-rw-r--r--cpp/src/slice2docbook/Main.cpp35
1 files changed, 31 insertions, 4 deletions
diff --git a/cpp/src/slice2docbook/Main.cpp b/cpp/src/slice2docbook/Main.cpp
index b7ffe832082..ffac6164b52 100644
--- a/cpp/src/slice2docbook/Main.cpp
+++ b/cpp/src/slice2docbook/Main.cpp
@@ -10,14 +10,25 @@
#include <IceUtil/Options.h>
#include <IceUtil/StringUtil.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;
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)
{
@@ -152,7 +163,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 = 1; idx < args.size(); ++idx)
{
@@ -186,12 +197,19 @@ 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)
{
- SignalHandler::addFileForCleanup(docbook);
-
Gen gen(argv[0], docbook, standAlone, chapter, noIndex, sortFields);
if(!gen)
{
@@ -203,5 +221,14 @@ main(int argc, char* argv[])
p->destroy();
+ {
+ IceUtil::StaticMutex::Lock lock(_mutex);
+
+ if(_interrupted)
+ {
+ return EXIT_FAILURE;
+ }
+ }
+
return status;
}