diff options
| author | Martin Cracauer <cracauer@FreeBSD.org> | 1998-08-24 10:17:20 +0000 |
|---|---|---|
| committer | Martin Cracauer <cracauer@FreeBSD.org> | 1998-08-24 10:17:20 +0000 |
| commit | 9a4902a99fd0225878dc081f5bc9599c84faad0d (patch) | |
| tree | 3d4beeb644c122859eb279c67eb698bebafcf05a /usr.bin/time | |
| parent | 2e809930bacaa9422dff829bf33caa300d7c472a (diff) | |
Notes
Diffstat (limited to 'usr.bin/time')
| -rw-r--r-- | usr.bin/time/time.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/usr.bin/time/time.c b/usr.bin/time/time.c index 707ba10ae68d..f74b6db8ae08 100644 --- a/usr.bin/time/time.c +++ b/usr.bin/time/time.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)time.c 8.1 (Berkeley) 6/6/93"; #endif static const char rcsid[] = - "$Id: time.c,v 1.9 1998/07/27 16:54:05 des Exp $"; + "$Id: time.c,v 1.10 1998/07/28 10:08:16 des Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -57,6 +57,7 @@ static const char rcsid[] = #include <stdio.h> #include <string.h> #include <unistd.h> +#include <signal.h> static int getstathz __P((void)); static void usage __P((void)); @@ -75,6 +76,7 @@ main(argc, argv) struct rusage ru; FILE *out = stderr; char *ofn = NULL; + int exitonsig = 0; /* Die with same signal as child */ aflag = lflag = 0; while ((ch = getopt(argc, argv, "alo:")) != -1) @@ -119,8 +121,10 @@ main(argc, argv) (void)signal(SIGQUIT, SIG_IGN); while (wait3(&status, 0, &ru) != pid); /* XXX use waitpid */ gettimeofday(&after, (struct timezone *)NULL); - if (status&0377) + if ( ! WIFEXITED(status)) warnx("command terminated abnormally"); + if (WIFSIGNALED(status)) + exitonsig = WTERMSIG(status); after.tv_sec -= before.tv_sec; after.tv_usec -= before.tv_usec; if (after.tv_usec < 0) @@ -173,6 +177,12 @@ main(argc, argv) fprintf(out, "%10ld %s\n", ru.ru_nivcsw, "involuntary context switches"); } + if (exitonsig) { + if (signal(exitonsig, SIG_DFL) < 0) + perror("signal"); + else + kill(getpid(), exitonsig); + } exit (WIFEXITED(status) ? WEXITSTATUS(status) : EXIT_FAILURE); } |
