Don't go busy loop when waiting child process.
Before this change, code works like this: after gets POLLHUP from poll, it just
go a busy loop to do poll -> waitpid -> poll -> waitpid ... until child process
really exit. This doesn't make sense and is waste of CPU.
Change-Id: If6cd8b0245587d623e309c3ae27f162e1c7ef504
Signed-off-by: Tao Wu <lepton@google.com>
diff --git a/logwrapper/logwrap.c b/logwrapper/logwrap.c
index 28d6de7..ccbe0bf 100644
--- a/logwrapper/logwrap.c
+++ b/logwrapper/logwrap.c
@@ -408,7 +408,7 @@
if (poll_fds[0].revents & POLLHUP) {
int ret;
- ret = waitpid(pid, &status, WNOHANG);
+ ret = TEMP_FAILURE_RETRY(waitpid(pid, &status, 0));
if (ret < 0) {
rc = errno;
ALOG(LOG_ERROR, "logwrap", "waitpid failed with %s\n", strerror(errno));