From bc31090b7a1784b765a171d82976a5ec410bfa1d Mon Sep 17 00:00:00 2001 From: Tao Wu Date: Tue, 16 Feb 2016 10:13:48 -0800 Subject: [PATCH] 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 --- logwrapper/logwrap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logwrapper/logwrap.c b/logwrapper/logwrap.c index 28d6de7fb..ccbe0bf28 100644 --- a/logwrapper/logwrap.c +++ b/logwrapper/logwrap.c @@ -408,7 +408,7 @@ static int parent(const char *tag, int parent_read, pid_t pid, 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));