diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2008-01-18 10:27:58 -0330 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2008-01-18 10:27:58 -0330 |
commit | 40da4a3aecbc259c472d77f58d1d6466af42e5ef (patch) | |
tree | 3780215d0441c84682c9c281b3187b78973a6b9e /cpp/src/Slice/Preprocessor.cpp | |
parent | Added Windows signal handling (diff) | |
download | ice-40da4a3aecbc259c472d77f58d1d6466af42e5ef.tar.bz2 ice-40da4a3aecbc259c472d77f58d1d6466af42e5ef.tar.xz ice-40da4a3aecbc259c472d77f58d1d6466af42e5ef.zip |
Windows fixes for translator interrupt cleanup
Diffstat (limited to 'cpp/src/Slice/Preprocessor.cpp')
-rw-r--r-- | cpp/src/Slice/Preprocessor.cpp | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp index d91bb1f069e..66474c113b7 100644 --- a/cpp/src/Slice/Preprocessor.cpp +++ b/cpp/src/Slice/Preprocessor.cpp @@ -27,6 +27,20 @@ using namespace std; using namespace Slice; // +// Callback for Crtl-C signal handling +// +static Preprocessor* _preprocess = 0; + +static void closeCallback() +{ + if(_preprocess != 0) + { + _preprocess->close(); + } +} + + +// // mcpp defines // namespace Slice @@ -49,14 +63,16 @@ Slice::Preprocessor::Preprocessor(const string& path, const string& fileName, co _args(args), _cppHandle(0) { + _preprocess = this; + SignalHandler::setCallback(closeCallback); } Slice::Preprocessor::~Preprocessor() { - if(_cppHandle) - { - close(); - } + _preprocess = 0; + SignalHandler::setCallback(0); + + close(); } string @@ -412,21 +428,22 @@ Slice::Preprocessor::printMakefileDependencies(Language lang, const vector<strin bool Slice::Preprocessor::close() { - assert(_cppHandle); - - int status = fclose(_cppHandle); - _cppHandle = 0; - - if(status != 0) + if(_cppHandle != 0) { - return false; - } + int status = fclose(_cppHandle); + _cppHandle = 0; + + if(status != 0) + { + return false; + } #ifdef _WIN32 - _unlink(_cppFile.c_str()); + _unlink(_cppFile.c_str()); #else - unlink(_cppFile.c_str()); + unlink(_cppFile.c_str()); #endif + } return true; } |