Index: job.c =================================================================== RCS file: /cvsroot/src/usr.bin/make/job.c,v retrieving revision 1.168 diff -u -p -u -r1.168 job.c --- job.c 2 Feb 2013 15:24:08 -0000 1.168 +++ job.c 5 Feb 2013 22:04:51 -0000 @@ -139,6 +139,7 @@ __RCSID("$NetBSD: job.c,v 1.168 2013/02/ #include #include +#include #include #include #ifndef USE_SELECT @@ -2040,32 +2041,64 @@ Job_CatchOutput(void) { int nready; Job *job; - int i, n; + int i; (void)fflush(stdout); /* The first fd in the list is the job token pipe */ - nready = poll(fds + 1 - wantToken, nfds - 1 + wantToken, POLL_MSEC); + do { + nready = poll(fds + 1 - wantToken, nfds - 1 + wantToken, POLL_MSEC); + } while (nready < 0 && errno == EINTR); + + if (nready < 0) + Punt("poll: %s", strerror(errno)); - if (nready < 0 || readyfd(&childExitJob)) { + if (nready > 0) { char token = 0; + ssize_t count; nready -= 1; - for (n = 0; n < 5 && - read(childExitJob.inPipe, &token, 1) == -1 && errno == EAGAIN; n++) - continue; - if (token == DO_JOB_RESUME[0]) - /* Complete relay requested from our SIGCONT handler */ - JobRestartJobs(); + do { +#if WTF +/* + * if the childExitJob had a readyfd, why not process it here? instead of + * the else. Why special-case it? + */ +#endif + count = read(childExitJob.inPipe, &token, 1); + } while (count < 0 && errno = EINTR); + if (count < 0) { + Punt("token pipe read: %s", strerror(errno)); + } else if (count == 0) { + Punt("unexpected eof on token pipe"); + } else { /* count > 0 */ + assert(count == 1); + if (token == DO_JOB_RESUME[0]) + /* Complete relay requested from our SIGCONT handler */ + JobRestartJobs(); + } + Job_CatchChildren(); + } else if (readyfd(&childExitJob)) { Job_CatchChildren(); } +#if WTF +/* Is this an optimization? */ if (nready <= 0) return; +#endif +#if WTF +/* + * What's the point of this? + */ if (wantToken && readyfd(&tokenWaitJob)) nready--; +#endif for (i = 2; i < nfds; i++) { +#ifdef WTF + /* Why not use nready here to cut things short? */ +#endif if (!fds[i].revents) continue; job = jobfds[i];