Brucifixion.
This commit is contained in:
parent
51f14853fd
commit
9b81ca853e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=37913
@ -39,8 +39,7 @@
|
||||
.Nd time command execution
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl l
|
||||
.Op Fl a
|
||||
.Op Fl al
|
||||
.Op Fl o Ar file
|
||||
.Ar command
|
||||
.Sh DESCRIPTION
|
||||
@ -68,15 +67,15 @@ process.
|
||||
.Pp
|
||||
Available options:
|
||||
.Bl -tag -width Ds
|
||||
.It Fl l
|
||||
The contents of the
|
||||
.Em rusage
|
||||
structure are printed as well.
|
||||
.It Fl a
|
||||
If the
|
||||
.Fl o
|
||||
flag is used, append to the specified file rather than overwriting
|
||||
it. Otherwise, this option has no effect.
|
||||
.It Fl l
|
||||
The contents of the
|
||||
.Em rusage
|
||||
structure are printed as well.
|
||||
.It Fl o Ar file
|
||||
Write the output to
|
||||
.Ar file
|
||||
@ -86,7 +85,6 @@ exists and the
|
||||
.Fl a
|
||||
flag is not specified, the file will be overwritten.
|
||||
.El
|
||||
.Sh NOTES
|
||||
.Pp
|
||||
The
|
||||
.Xr csh 1
|
||||
@ -98,27 +96,6 @@ is available as
|
||||
to
|
||||
.Xr csh
|
||||
users.
|
||||
The output of
|
||||
.Nm
|
||||
can be directed to standard output by specifying
|
||||
.Do
|
||||
-
|
||||
.Dc
|
||||
as the argument to the
|
||||
.Fl a
|
||||
or
|
||||
.Fl o
|
||||
option.
|
||||
.Pp
|
||||
The
|
||||
.Fl a
|
||||
and
|
||||
.Fl o
|
||||
options are mutually exclusive.
|
||||
.Sh BUGS
|
||||
The granularity of seconds on micro processors is crude and
|
||||
can result in times being reported for CPU usage which are too large by
|
||||
a second.
|
||||
.Sh SEE ALSO
|
||||
.Xr csh 1 ,
|
||||
.Xr getrusage 2 ,
|
||||
|
@ -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.8 1998/07/27 16:08:58 des Exp $";
|
||||
"$Id: time.c,v 1.9 1998/07/27 16:54:05 des Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -56,7 +56,6 @@ static const char rcsid[] =
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sysexits.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static int getstathz __P((void));
|
||||
@ -71,24 +70,24 @@ main(argc, argv)
|
||||
extern int optind;
|
||||
|
||||
register int pid;
|
||||
int ch, status, lflag, aflag = 0;
|
||||
int aflag, ch, lflag, status;
|
||||
struct timeval before, after;
|
||||
struct rusage ru;
|
||||
FILE *out = stderr;
|
||||
char *ofn = NULL;
|
||||
|
||||
lflag = 0;
|
||||
while ((ch = getopt(argc, argv, "lao:")) != -1)
|
||||
aflag = lflag = 0;
|
||||
while ((ch = getopt(argc, argv, "alo:")) != -1)
|
||||
switch((char)ch) {
|
||||
case 'a':
|
||||
aflag = 1;
|
||||
break;
|
||||
case 'o':
|
||||
ofn = optarg;
|
||||
break;
|
||||
case 'l':
|
||||
lflag = 1;
|
||||
break;
|
||||
case 'o':
|
||||
ofn = optarg;
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
@ -99,11 +98,9 @@ main(argc, argv)
|
||||
argv += optind;
|
||||
|
||||
if (ofn) {
|
||||
if (strcmp(ofn, "-") == 0)
|
||||
out = stdout;
|
||||
else
|
||||
if ((out = fopen(ofn, aflag?"a":"w")) == NULL)
|
||||
err(EX_IOERR, ofn);
|
||||
if ((out = fopen(ofn, aflag ? "a" : "w")) == NULL)
|
||||
err(1, "%s", ofn);
|
||||
setvbuf(out, (char *)NULL, _IONBF, (size_t)0);
|
||||
}
|
||||
|
||||
gettimeofday(&before, (struct timezone *)NULL);
|
||||
@ -182,8 +179,8 @@ main(argc, argv)
|
||||
static void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr, "usage: time [-l] [-a] [-o file] command\n");
|
||||
exit(EX_USAGE);
|
||||
fprintf(stderr, "usage: time [-al] [-o file] command\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user