diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2008-02-01 14:01:10 -0330 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2008-02-01 14:01:10 -0330 |
commit | ebf526bc944045bd6d9fc6ef9721c9f56e18151c (patch) | |
tree | a5249f0e9f8a048dfad3d8f67a4200f4d6f918d2 | |
parent | Fixed slice include directory (diff) | |
download | ice-ebf526bc944045bd6d9fc6ef9721c9f56e18151c.tar.bz2 ice-ebf526bc944045bd6d9fc6ef9721c9f56e18151c.tar.xz ice-ebf526bc944045bd6d9fc6ef9721c9f56e18151c.zip |
Bug 2672 - mcpp messing up interactive python/ruby demos
-rwxr-xr-x | cpp/src/Slice/Preprocessor.cpp | 21 | ||||
-rw-r--r-- | py/demo/Ice/hello/Server.py | 1 |
2 files changed, 19 insertions, 3 deletions
diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp index 68f68c1c851..eed134be39b 100755 --- a/cpp/src/Slice/Preprocessor.cpp +++ b/cpp/src/Slice/Preprocessor.cpp @@ -150,7 +150,16 @@ Slice::Preprocessor::preprocess(bool keepComments) { argv[i + 1] = (char*) args[i].c_str(); } - + + // + // Mcpp redirects stdin which causes problems for Python + // and Ruby applications which use loadSlice. Therefore + // we need to save handle to stdin so we can restore it + // after mcpp has finished its processing. + // + int stdin_save; + stdin_save = dup(0); + // // Call mcpp using memory buffer. // @@ -159,6 +168,14 @@ Slice::Preprocessor::preprocess(bool keepComments) delete[] argv; // + // Restore stdin. + // + fflush(stdin); + ::close(0); + dup2(stdin_save, 0); + ::close(stdin_save); + + // // Write output to temporary file. Print errors to stderr. // string result; @@ -167,7 +184,7 @@ Slice::Preprocessor::preprocess(bool keepComments) _cppFile = ".preprocess." + IceUtil::generateUUID(); SignalHandler::addFile(_cppFile); #ifdef _WIN32 - _cppHandle = ::_wfopen(IceUtil::stringToWstring(_cppFile).c_str(), IceUtil::stringToWstring("w+").c_str()); + _cppHandle = ::_fopen(_cppFile.c_str(), "w+"); #else _cppHandle = ::fopen(_cppFile.c_str(), "w+"); #endif diff --git a/py/demo/Ice/hello/Server.py b/py/demo/Ice/hello/Server.py index 14139ec5c62..47e7a070736 100644 --- a/py/demo/Ice/hello/Server.py +++ b/py/demo/Ice/hello/Server.py @@ -34,7 +34,6 @@ class Server(Ice.Application): self.communicator().waitForShutdown() return 0 -print "hello world" sys.stdout.flush() app = Server() sys.exit(app.main(sys.argv, "config.server")) |