From 2ec9a48fa0bdde21b7167faa83f259a4e5c7c7dd Mon Sep 17 00:00:00 2001 From: "K. Noel Belcourt" Date: Mon, 12 Nov 2007 22:52:12 +0000 Subject: [PATCH] Get the unix timing working correctly. [SVN r41048] --- historic/jam/src/execunix.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/historic/jam/src/execunix.c b/historic/jam/src/execunix.c index e937a743e..612658447 100644 --- a/historic/jam/src/execunix.c +++ b/historic/jam/src/execunix.c @@ -65,6 +65,7 @@ static struct timeval tv; static int select_timeout = 0; static int intr = 0; static int cmdsrunning = 0; +static struct tms old_time; #define OUT 0 #define ERR 1 @@ -110,6 +111,7 @@ execcmd( char *action, char *target ) { + static int initialized = 0; int out[2], err[2]; int slot, len; char *argv[ MAXARGC + 1 ]; /* +1 for NULL */ @@ -170,6 +172,12 @@ execcmd( cmdtab[ slot ].command = BJAM_MALLOC_ATOMIC(strlen(string)+1); strcpy(cmdtab[slot].command, string); + /* initialize only once */ + if ( ! initialized ) { + times(&old_time); + initialized = 1; + } + /* create pipe from child to parent */ if (pipe(out) < 0) @@ -412,7 +420,7 @@ execwait() int rstat; timing_info time; fd_set fds; - struct tms old_time, new_time; + struct tms new_time; /* Handle naive make1() which doesn't know if cmds are running. */ @@ -476,8 +484,6 @@ execwait() cmdtab[i].exit_reason = EXIT_FAIL; } - times(&old_time); - /* print out the rule and target name */ out_action(cmdtab[i].action, cmdtab[i].target, cmdtab[i].command, cmdtab[i].buffer[OUT], cmdtab[i].buffer[ERR], @@ -488,6 +494,8 @@ execwait() time.system = (double)(new_time.tms_cstime - old_time.tms_cstime) / CLOCKS_PER_SEC; time.user = (double)(new_time.tms_cutime - old_time.tms_cutime) / CLOCKS_PER_SEC; + old_time = new_time; + /* Drive the completion */ --cmdsrunning;