diff options
author | Jose <jose@zeroc.com> | 2019-05-30 10:26:14 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2019-06-04 12:54:24 +0200 |
commit | aa2abfbe1cc4df400a652955ece9f7bf7df56616 (patch) | |
tree | 3dd49667591975e10789db26178c894c24aadc1b /cpp | |
parent | Fixed trailing whitespace (diff) | |
download | ice-aa2abfbe1cc4df400a652955ece9f7bf7df56616.tar.bz2 ice-aa2abfbe1cc4df400a652955ece9f7bf7df56616.tar.xz ice-aa2abfbe1cc4df400a652955ece9f7bf7df56616.zip |
Fix the reading of the error message from the Service class #407
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/src/Ice/Service.cpp | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/cpp/src/Ice/Service.cpp b/cpp/src/Ice/Service.cpp index b0d05c2aeb5..9642c46617a 100644 --- a/cpp/src/Ice/Service.cpp +++ b/cpp/src/Ice/Service.cpp @@ -1585,37 +1585,30 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa // // Read an error message. // - char msg[1024]; - size_t pos = 0; - while(pos < sizeof(msg)) + ssize_t rs; + char s[16]; + string message; + while((rs = read(fds[0], &s, 16)) > 0) { - ssize_t n = read(fds[0], &msg[pos], sizeof(msg) - pos); - if(n == -1) - { - if(IceInternal::interrupted()) - { - continue; - } - - if(argv[0]) - { - consoleErr << ": "; - } - consoleErr << "I/O error while reading error message from child:\n" - << IceUtilInternal::errorToString(errno) << endl; - _exit(EXIT_FAILURE); - } - pos += n; - break; + message.append(s, rs); } + if(argv[0]) { consoleErr << argv[0] << ": "; } - consoleErr << "failure occurred in daemon"; - if(strlen(msg) > 0) + + if(rs == -1) + { + consoleErr << "I/O error while reading error message from child:\n" << IceUtilInternal::errorToString(errno); + } + else { - consoleErr << ':' << endl << msg; + consoleErr << "failure occurred in daemon"; + if(!message.empty()) + { + consoleErr << ":\n" << message; + } } consoleErr << endl; _exit(EXIT_FAILURE); |