diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2015-09-01 15:19:00 +0200 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2015-09-01 15:19:00 +0200 |
commit | 0c05cd0b662c924d21d1afbf07151d9ddb1255c9 (patch) | |
tree | 655359b2813ecd3ec880d70a7d7f2c7773de4eaa | |
parent | 72e27cf6a21273dd79b17aa187b24099ca082ce2 (diff) | |
download | redo-c-0c05cd0b662c924d21d1afbf07151d9ddb1255c9.tar.gz redo-c-0c05cd0b662c924d21d1afbf07151d9ddb1255c9.tar.xz redo-c-0c05cd0b662c924d21d1afbf07151d9ddb1255c9.zip |
vacate properly
-rw-r--r-- | redo.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/redo.c b/redo.c index 7e9a53f..d0a38d5 100644 --- a/redo.c +++ b/redo.c @@ -393,6 +393,14 @@ check_deps(char *target) return ok; } +void +vacate(int implicit) { + if (implicit) + implicit_jobs++; + else + write(poolwr_fd, "\0", 1); +} + struct job { struct job *next; pid_t pid; @@ -470,6 +478,7 @@ run_script(char *target, int implicit) pid = fork(); if (pid < 0) { perror("fork"); + vacate(implicit); exit(-1); } else if (pid == 0) { // child /* @@ -501,6 +510,7 @@ djb-style default.o.do: else execl(dofile, dofile, target, basename, temp_target, (char *) 0); + vacate(implicit); exit(-1); } else { close(dep_fd); @@ -519,8 +529,6 @@ djb-style default.o.do: return job; } - - // XXX vacate job when error happened before } static int @@ -572,7 +580,7 @@ create_pool() poolwr_fd = fds[1]; for (i = 0; i < jobs-1; i++) - write(poolwr_fd, "\0", 1); + vacate(0); setenvfd("REDO_RD_FD", poolrd_fd); setenvfd("REDO_WR_FD", poolwr_fd); @@ -656,11 +664,8 @@ redo_ifchange(int targetc, char *targetv[]) rename(job->temp_target, target); } } - - if (job->implicit) - implicit_jobs++; - else - write(poolwr_fd, "\0", 1); + + vacate(job->implicit); if (kflag < 0 && status > 0) { printf("failed with status %d\n", status); |