Skip to content

Commit

Permalink
Handle interrupted system calls
Browse files Browse the repository at this point in the history
  • Loading branch information
davidar committed Jun 2, 2024
1 parent 2138d35 commit 874de40
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/samu/build.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,15 @@ jobdone(struct job *j)
int status;
struct edge *e, *new;
struct pool *p;
int ret;

++nfinished;
if (waitpid(j->pid, &status, 0) < 0) {
while ((ret = waitpid(j->pid, &status, 0)) < 0) {
if (errno == EINTR)
continue;
break;
}
if (ret < 0) {
warn("waitpid %d:", j->pid);
j->failed = true;
} else if (WIFEXITED(status)) {
Expand Down Expand Up @@ -599,8 +605,11 @@ build(void)
}
if (numjobs == 0)
break;
if (poll(fds, jobslen, 5000) < 0)
while (poll(fds, jobslen, 5000) < 0) {
if (errno == EINTR)
continue;
fatal("poll:");
}
for (i = 0; i < jobslen; ++i) {
if (!fds[i].revents || jobwork(&jobs[i]))
continue;
Expand Down

0 comments on commit 874de40

Please sign in to comment.