2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-16 01:12:13 +00:00

Renamed variables used in timeout code so I don't make

silly mistakes like using a negative time for the select
timeout.  

Also added the setrlimit call back in since the
named_condition_test occassionally consumes multiple cpus
worth of time.  That is, when I ran this test -j4, I found
the named_condition test consuming 4 cpus worth of time so
after 300 seconds of elapsed time when the test timed out, 
it had consumed almost 1200 seconds worth of cpu.  While the 
test is killed after the elapsed time expired, setting a hard 
cpu limit ensures it's killed after consuming either -lx seconds 
worth of cpu or -lx seconds of elapsed time.



[SVN r39613]
This commit is contained in:
K. Noel Belcourt
2007-09-29 21:47:24 +00:00
parent b9c16aaaaa
commit 870b60470e

View File

@@ -62,7 +62,7 @@
static clock_t tps = 0;
static struct timeval tv;
static int timeout = 0;
static int select_timeout = 0;
static int intr = 0;
static int cmdsrunning = 0;
@@ -221,6 +221,13 @@ execcmd(
* we use killpg(pid, SIGKILL) to kill the
* process group leader and all its children.
*/
if (0 < globs.timeout)
{
struct rlimit r_limit;
r_limit.rlim_cur = globs.timeout;
r_limit.rlim_max = globs.timeout;
setrlimit(RLIMIT_CPU, &r_limit);
}
setpgid(cmdtab[slot].pid, cmdtab[slot].pid);
execvp( argv[0], argv );
@@ -358,7 +365,7 @@ void populate_file_descriptors(int *fmax, fd_set *fds)
int i, fd_max = 0;
struct tms buf;
clock_t current = times(&buf);
timeout = globs.timeout;
select_timeout = globs.timeout;
/* compute max read file descriptor for use in select */
FD_ZERO(fds);
@@ -380,8 +387,9 @@ void populate_file_descriptors(int *fmax, fd_set *fds)
if (globs.timeout && cmdtab[i].pid) {
clock_t consumed = (current - cmdtab[i].start_time) / tps;
if (0 <= (globs.timeout - consumed) && ((globs.timeout - consumed) < timeout)) {
timeout = globs.timeout - consumed;
clock_t process_timesout = globs.timeout - consumed;
if (0 < process_timesout && process_timesout < select_timeout) {
select_timeout = process_timesout;
}
if (globs.timeout <= consumed) {
killpg(cmdtab[i].pid, SIGKILL);
@@ -420,7 +428,7 @@ execwait()
if (0 < globs.timeout) {
/* force select to timeout so we can terminate expired processes */
tv.tv_sec = timeout;
tv.tv_sec = select_timeout;
tv.tv_usec = 0;
/* select will wait until: io on a descriptor, a signal, or we time out */