70 |
return; |
return; |
71 |
} |
} |
72 |
} |
} |
73 |
resp->elapsed_ms = (monotonic_us() / 1000) - resp->elapsed_ms; |
resp->elapsed_ms = monotonic_ms() - resp->elapsed_ms; |
74 |
} |
} |
75 |
|
|
76 |
static void printargv(char *const *argv) |
static void printargv(char *const *argv) |
89 |
This is funky since the pagesize could be less than 1K. |
This is funky since the pagesize could be less than 1K. |
90 |
Note: Some machines express getrusage statistics in terms of K, |
Note: Some machines express getrusage statistics in terms of K, |
91 |
others in terms of pages. */ |
others in terms of pages. */ |
92 |
static unsigned long ptok(unsigned pagesize, unsigned long pages) |
static unsigned long ptok(const unsigned pagesize, const unsigned long pages) |
93 |
{ |
{ |
94 |
unsigned long tmp; |
unsigned long tmp; |
95 |
|
|
303 |
printf("%lu", ptok(pagesize, (UL) resp->ru.ru_ixrss) / cpu_ticks); |
printf("%lu", ptok(pagesize, (UL) resp->ru.ru_ixrss) / cpu_ticks); |
304 |
break; |
break; |
305 |
case 'Z': /* Page size. */ |
case 'Z': /* Page size. */ |
306 |
printf("%u", getpagesize()); |
printf("%u", pagesize); |
307 |
break; |
break; |
308 |
case 'c': /* Involuntary context switches. */ |
case 'c': /* Involuntary context switches. */ |
309 |
printf("%lu", resp->ru.ru_nivcsw); |
printf("%lu", resp->ru.ru_nivcsw); |
371 |
void (*interrupt_signal)(int); |
void (*interrupt_signal)(int); |
372 |
void (*quit_signal)(int); |
void (*quit_signal)(int); |
373 |
|
|
374 |
resp->elapsed_ms = monotonic_us() / 1000; |
resp->elapsed_ms = monotonic_ms(); |
375 |
pid = vfork(); /* Run CMD as child process. */ |
pid = vfork(); /* Run CMD as child process. */ |
376 |
if (pid < 0) |
if (pid < 0) |
377 |
bb_perror_msg_and_die("fork"); |
bb_perror_msg_and_die("fork"); |
380 |
versus merely warnings if the cast is left off. */ |
versus merely warnings if the cast is left off. */ |
381 |
BB_EXECVP(cmd[0], cmd); |
BB_EXECVP(cmd[0], cmd); |
382 |
xfunc_error_retval = (errno == ENOENT ? 127 : 126); |
xfunc_error_retval = (errno == ENOENT ? 127 : 126); |
383 |
bb_error_msg_and_die("cannot run %s", cmd[0]); |
bb_error_msg_and_die("can't run %s", cmd[0]); |
384 |
} |
} |
385 |
|
|
386 |
/* Have signals kill the child but not self (if possible). */ |
/* Have signals kill the child but not self (if possible). */ |
414 |
run_command(argv, &res); |
run_command(argv, &res); |
415 |
|
|
416 |
/* Cheat. printf's are shorter :) */ |
/* Cheat. printf's are shorter :) */ |
417 |
/* (but see bb_putchar() body for additional wrinkle!) */ |
xdup2(STDERR_FILENO, STDOUT_FILENO); |
|
xdup2(2, 1); /* just in case libc does something silly :( */ |
|
|
stdout = stderr; |
|
418 |
summarize(output_format, argv, &res); |
summarize(output_format, argv, &res); |
419 |
|
|
420 |
if (WIFSTOPPED(res.waitstatus)) |
if (WIFSTOPPED(res.waitstatus)) |