version 1.10, 2001/11/19 19:02:16 |
version 1.11, 2001/11/22 10:42:39 |
|
|
#include <sys/resource.h> |
#include <sys/resource.h> |
#include <sys/wait.h> |
#include <sys/wait.h> |
#include <sys/sysctl.h> |
#include <sys/sysctl.h> |
|
|
|
#include <err.h> |
|
#include <errno.h> |
#include <signal.h> |
#include <signal.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <err.h> |
|
#include <unistd.h> |
#include <unistd.h> |
#include <errno.h> |
|
|
|
int lflag; |
int lflag; |
int portableflag; |
int portableflag; |
|
|
|
__dead void usage __P((void)); |
|
|
int |
int |
main(argc, argv) |
main(argc, argv) |
int argc; |
int argc; |
char **argv; |
char **argv; |
{ |
{ |
extern int optind; |
|
int pid; |
int pid; |
int ch, status; |
int ch, status; |
struct timeval before, after; |
struct timeval before, after; |
struct rusage ru; |
struct rusage ru; |
int exitonsig = 0; |
int exitonsig = 0; |
|
|
lflag = 0; |
|
while ((ch = getopt(argc, argv, "lp")) != -1) |
while ((ch = getopt(argc, argv, "lp")) != -1) { |
switch((char)ch) { |
switch(ch) { |
case 'p': |
|
portableflag = 1; |
|
break; |
|
case 'l': |
case 'l': |
lflag = 1; |
lflag = 1; |
break; |
break; |
|
case 'p': |
|
portableflag = 1; |
|
break; |
case '?': |
case '?': |
default: |
default: |
fprintf(stderr, "usage: time [-lp] command.\n"); |
usage(); |
exit(1); |
/* NOTREACHED */ |
} |
} |
|
} |
|
|
if (!(argc -= optind)) |
argc -= optind; |
exit(0); |
|
argv += optind; |
argv += optind; |
|
|
|
if (argc < 1) |
|
usage(); |
|
|
gettimeofday(&before, (struct timezone *)NULL); |
gettimeofday(&before, (struct timezone *)NULL); |
switch(pid = vfork()) { |
switch(pid = vfork()) { |
|
|
kill(getpid(), exitonsig); |
kill(getpid(), exitonsig); |
} |
} |
exit(WIFEXITED(status) ? WEXITSTATUS(status) : EXIT_FAILURE); |
exit(WIFEXITED(status) ? WEXITSTATUS(status) : EXIT_FAILURE); |
|
} |
|
|
|
__dead void |
|
usage() |
|
{ |
|
extern char *__progname; |
|
|
|
(void)fprintf(stderr, "usage: %s [-lp] command\n", __progname); |
|
exit(1); |
} |
} |