diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2008-11-19 11:06:31 -0330 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2008-11-19 11:06:31 -0330 |
commit | 7f24f7fd2361ff5d43775e4523bc78ffdb108306 (patch) | |
tree | 62d26962d53259163ee997a7172af5a8fb550a1d /cpp/src/slice2cpp/Gen.cpp | |
parent | Bug 3541 - Slice signal handling unsafe (diff) | |
download | ice-7f24f7fd2361ff5d43775e4523bc78ffdb108306.tar.bz2 ice-7f24f7fd2361ff5d43775e4523bc78ffdb108306.tar.xz ice-7f24f7fd2361ff5d43775e4523bc78ffdb108306.zip |
Added use of CtrlChandler to slice compilers
Diffstat (limited to 'cpp/src/slice2cpp/Gen.cpp')
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 4c0eb293823..73a3673e655 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -23,6 +23,19 @@ using namespace Slice; using namespace IceUtil; using namespace IceUtilInternal; +// +// Callback for Crtl-C signal handling +// +static Gen* _gen = 0; + +static void closeCallback() +{ + if(_gen != 0) + { + _gen->closeOutput(); + } +} + static string getDeprecateSymbol(const ContainedPtr& p1, const ContainedPtr& p2) { @@ -51,6 +64,9 @@ Slice::Gen::Gen(const string& name, const string& base, const string& headerExte _stream(stream), _ice(ice) { + _gen = this; + SignalHandler::setCloseCallback(closeCallback); + for(vector<string>::iterator p = _includePaths.begin(); p != _includePaths.end(); ++p) { *p = fullPath(*p); @@ -71,8 +87,6 @@ Slice::Gen::Gen(const string& name, const string& base, const string& headerExte fileImplH = dir + '/' + fileImplH; fileImplC = dir + '/' + fileImplC; } - SignalHandler::addFile(fileImplH); - SignalHandler::addFile(fileImplC); struct stat st; if(stat(fileImplH.c_str(), &st) == 0) @@ -86,6 +100,7 @@ Slice::Gen::Gen(const string& name, const string& base, const string& headerExte return; } + SignalHandler::addFileForCleanup(fileImplH); implH.open(fileImplH.c_str()); if(!implH) { @@ -93,6 +108,7 @@ Slice::Gen::Gen(const string& name, const string& base, const string& headerExte return; } + SignalHandler::addFileForCleanup(fileImplC); implC.open(fileImplC.c_str()); if(!implC) { @@ -118,9 +134,8 @@ Slice::Gen::Gen(const string& name, const string& base, const string& headerExte fileH = dir + '/' + fileH; fileC = dir + '/' + fileC; } - SignalHandler::addFile(fileH); - SignalHandler::addFile(fileC); + SignalHandler::addFileForCleanup(fileH); H.open(fileH.c_str()); if(!H) { @@ -128,6 +143,7 @@ Slice::Gen::Gen(const string& name, const string& base, const string& headerExte return; } + SignalHandler::addFileForCleanup(fileC); C.open(fileC.c_str()); if(!C) { @@ -161,6 +177,9 @@ Slice::Gen::~Gen() implH << "\n\n#endif\n"; implC << '\n'; } + + _gen = 0; + SignalHandler::setCloseCallback(0); } bool |