Boost logo

Boost-Commit :

From: kbelco_at_[hidden]
Date: 2007-09-17 22:42:15


Author: noel_belcourt
Date: 2007-09-17 22:42:13 EDT (Mon, 17 Sep 2007)
New Revision: 39360
URL: http://svn.boost.org/trac/boost/changeset/39360

Log:
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.

Text files modified:
   trunk/tools/jam/src/execunix.c | 17 +++++++++++------
   1 files changed, 11 insertions(+), 6 deletions(-)

Modified: trunk/tools/jam/src/execunix.c
==============================================================================
--- trunk/tools/jam/src/execunix.c (original)
+++ trunk/tools/jam/src/execunix.c 2007-09-17 22:42:13 EDT (Mon, 17 Sep 2007)
@@ -375,6 +375,15 @@
                 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 @@
         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<globs.jobs; ++i) {
                 if (0 < cmdtab[i].pid) {
                     clock_t current = times(&buf);
- if (globs.timeout <= (current-cmdtab[i].start_time)/tps) {
- kill(cmdtab[i].pid, SIGKILL);
- }
+ kill(cmdtab[i].pid, SIGKILL);
                 }
             }
             /* select will wait until io on a descriptor or a signal */


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk