From f3757f460aa0a3f25e8a25da31948feb68f9c56b Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 13 May 2008 16:44:59 +0000 Subject: QPID-1054: Fixed reporting of startup failures in daemon mode. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@655944 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/broker/Daemon.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'cpp') diff --git a/cpp/src/qpid/broker/Daemon.cpp b/cpp/src/qpid/broker/Daemon.cpp index a42f503708..0c2092021f 100644 --- a/cpp/src/qpid/broker/Daemon.cpp +++ b/cpp/src/qpid/broker/Daemon.cpp @@ -118,11 +118,13 @@ void Daemon::fork() } catch (const exception& e) { QPID_LOG(critical, "Daemon startup failed: " << e.what()); - stringstream pipeFailureMessage; - pipeFailureMessage << "0 " << e.what() << endl; + uint16_t port = 0; + write(pipeFds[1], &port, sizeof(uint16_t)); + + std::string pipeFailureMessage = e.what(); write ( pipeFds[1], - pipeFailureMessage.str().c_str(), - strlen(pipeFailureMessage.str().c_str()) + pipeFailureMessage.c_str(), + strlen(pipeFailureMessage.c_str()) ); } } @@ -176,11 +178,11 @@ uint16_t Daemon::wait(int timeout) { // parent waits for child. // Get Message string errmsg; - while ( 1 ) { - if ( 1 > ::read(pipeFds[0], &c, 1) ) - throw Exception("Daemon startup failed"+ - (errmsg.empty() ? string(".") : ": " + errmsg)); - } + do { + errmsg += c; + } while (::read(pipeFds[0], &c, 1)); + throw Exception("Daemon startup failed"+ + (errmsg.empty() ? string(".") : ": " + errmsg)); } return port; -- cgit v1.2.1