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>
This commit is contained in:
Tao Wu 2016-02-16 10:13:48 -08:00
parent 1c3d784030
commit bc31090b7a
1 changed files with 1 additions and 1 deletions

View File

@ -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));