aboutsummaryrefslogtreecommitdiffhomepage
path: root/proc.cpp
diff options
context:
space:
mode:
authorGravatar Kevin Ballard <kevin@sb.org>2015-01-12 22:26:07 -0800
committerGravatar Kevin Ballard <kevin@sb.org>2015-01-12 22:26:07 -0800
commit6e2132e01f08123436011f4bed07548d23784560 (patch)
tree1b89394cabb7acb10ae26968edaf8607beb8522b /proc.cpp
parent34db67680dd307bf5c60f46b1f723be2c803e32a (diff)
Reap jobs before calling select() in job_continue()
Prior to b0e09303a, simple jobs like `printf "%s\n" $line | read word _` never hit the call to select() because they were reaped in the SIGCHLD signal handler. With that commit, the signal handler no longer reaps children, and a job like that would enter select() and hit the 10000μs timeout before discovering that the job was already complete. Fixes #1884.
Diffstat (limited to 'proc.cpp')
-rw-r--r--proc.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/proc.cpp b/proc.cpp
index 649fc08a..e6e0a8ed 100644
--- a/proc.cpp
+++ b/proc.cpp
@@ -1012,6 +1012,9 @@ static int select_try(job_t *j)
tv.tv_usec=10000;
retval =select(maxfd+1, &fds, 0, 0, &tv);
+ if (retval == 0) {
+ debug(3, L"select_try hit timeout\n");
+ }
return retval > 0;
}
@@ -1224,6 +1227,9 @@ void job_continue(job_t *j, bool cont)
{
bool quit = false;
+ /* Look for finished processes first, to avoid select() if it's already done. */
+ process_mark_finished_children(false);
+
/*
Wait for job to report.
*/