From 445da99019bef56ed65d3d43e7e240cd8317fc50 Mon Sep 17 00:00:00 2001 From: "K. Noel Belcourt" Date: Tue, 18 Sep 2007 02:42:13 +0000 Subject: [PATCH] Fix One more obscure way for the timeout to miss processes. If select times out (no processes terminated), then all running processes can be terminated. Cleaned up code when this condition applies. [SVN r39360] --- src/engine/execunix.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/engine/execunix.c b/src/engine/execunix.c index f2718a3de..cc39313dc 100644 --- a/src/engine/execunix.c +++ b/src/engine/execunix.c @@ -375,6 +375,15 @@ void populate_file_descriptors(int *fmax, fd_set *fds) FD_SET(cmdtab[i].fd[ERR], fds); } } + + if (globs.timeout && cmdtab[i].pid) { + struct tms buf; + clock_t tps = sysconf(_SC_CLK_TCK); + clock_t current = times(&buf); + if (globs.timeout <= (current-cmdtab[i].start_time)/tps) { + kill(cmdtab[i].pid, SIGKILL); + } + } } *fmax = fd_max; } @@ -422,15 +431,11 @@ execwait() ret = select(fd_max+1, &fds, 0, 0, tv_ptr); if (0 == ret) { - clock_t tps = sysconf(_SC_CLK_TCK); - - /* select timed out, check for expired processes */ + /* select timed out, all processes have expired, kill them */ for (i=0; i