diff options
author | Chris Wilson <chris+github@qwirx.com> | 2015-07-31 06:41:01 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2015-07-31 06:41:01 +0000 |
commit | 018a593ccbb3d6cc48236ba3e279156054c15bbc (patch) | |
tree | eb8bbdb8eb3a8c77e4ceba36872143dec82332a9 /lib/server | |
parent | c9536cf6e81a25e735634141df78d7314f6fa138 (diff) |
Fix ServerStream logging too many messages when waiting for a child to die.
Detect that there are no remaining children to wait for, and return quietly.
Diffstat (limited to 'lib/server')
-rw-r--r-- | lib/server/ServerStream.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/server/ServerStream.h b/lib/server/ServerStream.h index 8bb52b5b..3f6eed7e 100644 --- a/lib/server/ServerStream.h +++ b/lib/server/ServerStream.h @@ -17,6 +17,7 @@ #include <sys/wait.h> #endif +#include "autogen_ServerException.h" #include "Daemon.h" #include "SocketListen.h" #include "Utils.h" @@ -344,10 +345,20 @@ public: p = ::waitpid(0 /* any child in process group */, &status, WNOHANG); - if(p == -1 && errno != ECHILD && errno != EINTR) + if(p == -1) { - THROW_EXCEPTION(ServerException, - ServerWaitOnChildError) + if (errno == ECHILD || errno == EINTR) + { + // Nothing actually happened, so there's no reason + // to wait again. + break; + } + else + { + THROW_SYS_ERROR("Failed to wait for daemon child " + "process", ServerException, + ServerWaitOnChildError); + } } else if(p == 0) { |