diff options
Diffstat (limited to 'miscutils/time.c')
-rw-r--r-- | miscutils/time.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/miscutils/time.c b/miscutils/time.c index d21944e01..677ca6d8b 100644 --- a/miscutils/time.c +++ b/miscutils/time.c | |||
@@ -61,7 +61,7 @@ static const char long_format[] ALIGN1 = | |||
61 | Return 0 on error, 1 if ok. */ | 61 | Return 0 on error, 1 if ok. */ |
62 | 62 | ||
63 | /* pid_t is short on BSDI, so don't try to promote it. */ | 63 | /* pid_t is short on BSDI, so don't try to promote it. */ |
64 | static int resuse_end(pid_t pid, resource_t * resp) | 64 | static int resuse_end(pid_t pid, resource_t *resp) |
65 | { | 65 | { |
66 | int status; | 66 | int status; |
67 | pid_t caught; | 67 | pid_t caught; |
@@ -69,7 +69,7 @@ static int resuse_end(pid_t pid, resource_t * resp) | |||
69 | /* Ignore signals, but don't ignore the children. When wait3 | 69 | /* Ignore signals, but don't ignore the children. When wait3 |
70 | returns the child process, set the time the command finished. */ | 70 | returns the child process, set the time the command finished. */ |
71 | while ((caught = wait3(&status, 0, &resp->ru)) != pid) { | 71 | while ((caught = wait3(&status, 0, &resp->ru)) != pid) { |
72 | if (caught == -1) | 72 | if (caught == -1 && errno != EINTR) |
73 | return 0; | 73 | return 0; |
74 | } | 74 | } |
75 | resp->elapsed_ms = (monotonic_us() / 1000) - resp->elapsed_ms; | 75 | resp->elapsed_ms = (monotonic_us() / 1000) - resp->elapsed_ms; |
@@ -373,24 +373,26 @@ static void summarize(const char *fmt, char **command, resource_t * resp) | |||
373 | 373 | ||
374 | /* Run command CMD and return statistics on it. | 374 | /* Run command CMD and return statistics on it. |
375 | Put the statistics in *RESP. */ | 375 | Put the statistics in *RESP. */ |
376 | static void run_command(char *const *cmd, resource_t * resp) | 376 | static void run_command(char *const *cmd, resource_t *resp) |
377 | { | 377 | { |
378 | pid_t pid; /* Pid of child. */ | 378 | pid_t pid; /* Pid of child. */ |
379 | __sighandler_t interrupt_signal, quit_signal; | 379 | void (*interrupt_signal)(int); |
380 | void (*quit_signal)(int); | ||
380 | 381 | ||
381 | resp->elapsed_ms = monotonic_us() / 1000; | 382 | resp->elapsed_ms = monotonic_us() / 1000; |
382 | pid = vfork(); /* Run CMD as child process. */ | 383 | pid = vfork(); /* Run CMD as child process. */ |
383 | if (pid < 0) | 384 | if (pid < 0) |
384 | bb_error_msg_and_die("cannot fork"); | 385 | bb_error_msg_and_die("cannot fork"); |
385 | else if (pid == 0) { /* If child. */ | 386 | if (pid == 0) { /* If child. */ |
386 | /* Don't cast execvp arguments; that causes errors on some systems, | 387 | /* Don't cast execvp arguments; that causes errors on some systems, |
387 | versus merely warnings if the cast is left off. */ | 388 | versus merely warnings if the cast is left off. */ |
388 | BB_EXECVP(cmd[0], cmd); | 389 | BB_EXECVP(cmd[0], cmd); |
389 | bb_error_msg("cannot run %s", cmd[0]); | 390 | xfunc_error_retval = (errno == ENOENT ? 127 : 126); |
390 | _exit(errno == ENOENT ? 127 : 126); | 391 | bb_error_msg_and_die("cannot run %s", cmd[0]); |
391 | } | 392 | } |
392 | 393 | ||
393 | /* Have signals kill the child but not self (if possible). */ | 394 | /* Have signals kill the child but not self (if possible). */ |
395 | //TODO: just block all sigs? and reenable them in the very end in main? | ||
394 | interrupt_signal = signal(SIGINT, SIG_IGN); | 396 | interrupt_signal = signal(SIGINT, SIG_IGN); |
395 | quit_signal = signal(SIGQUIT, SIG_IGN); | 397 | quit_signal = signal(SIGQUIT, SIG_IGN); |
396 | 398 | ||