diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-12-14 02:56:45 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-12-14 02:56:45 +0000 |
commit | d92d1f35ac3c4517a1fcbeed0cc54d1484a15cd3 (patch) | |
tree | be9708ddbf839feb2ddf4534dd0d785b7d48c1d4 /usr.bin | |
parent | 010830167f1579c5d713419f43c422770cb095b7 (diff) |
from netbsd; also print elapsed time
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/lastcomm/Makefile | 4 | ||||
-rw-r--r-- | usr.bin/lastcomm/lastcomm.1 | 4 | ||||
-rw-r--r-- | usr.bin/lastcomm/lastcomm.c | 14 |
3 files changed, 17 insertions, 5 deletions
diff --git a/usr.bin/lastcomm/Makefile b/usr.bin/lastcomm/Makefile index 5c174f74b55..1d6120284b8 100644 --- a/usr.bin/lastcomm/Makefile +++ b/usr.bin/lastcomm/Makefile @@ -1,6 +1,8 @@ -# $NetBSD: Makefile,v 1.4 1994/12/22 01:06:58 jtc Exp $ +# $NetBSD: Makefile,v 1.5 1995/10/22 01:43:40 ghudson Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 PROG= lastcomm +DPADD= ${LIBMATH} +LDADD= -lm .include <bsd.prog.mk> diff --git a/usr.bin/lastcomm/lastcomm.1 b/usr.bin/lastcomm/lastcomm.1 index 431b1885048..f4e72077952 100644 --- a/usr.bin/lastcomm/lastcomm.1 +++ b/usr.bin/lastcomm/lastcomm.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: lastcomm.1,v 1.4.2.1 1995/10/22 01:45:09 ghudson Exp $ +.\" $NetBSD: lastcomm.1,v 1.5 1995/10/22 01:43:41 ghudson Exp $ .\" .\" Copyright (c) 1980, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -98,6 +98,8 @@ The command name under which the process was called. The amount of cpu time used by the process (in seconds). .It The time the process started. +.It +The elapsed time of the process. .El .Pp The flags are encoded as follows: ``S'' indicates the command was diff --git a/usr.bin/lastcomm/lastcomm.c b/usr.bin/lastcomm/lastcomm.c index f4b88e814ea..5069d0618a2 100644 --- a/usr.bin/lastcomm/lastcomm.c +++ b/usr.bin/lastcomm/lastcomm.c @@ -1,4 +1,4 @@ -/* $NetBSD: lastcomm.c,v 1.7.2.1 1995/10/12 06:55:13 jtc Exp $ */ +/* $NetBSD: lastcomm.c,v 1.9 1995/10/22 01:43:42 ghudson Exp $ */ /* * Copyright (c) 1980, 1993 @@ -43,7 +43,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)lastcomm.c 8.2 (Berkeley) 4/29/95"; #endif -static char rcsid[] = "$NetBSD: lastcomm.c,v 1.7.2.1 1995/10/12 06:55:13 jtc Exp $"; +static char rcsid[] = "$NetBSD: lastcomm.c,v 1.9 1995/10/22 01:43:42 ghudson Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -53,10 +53,12 @@ static char rcsid[] = "$NetBSD: lastcomm.c,v 1.7.2.1 1995/10/12 06:55:13 jtc Exp #include <ctype.h> #include <err.h> #include <fcntl.h> +#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <struct.h> +#include <tzfile.h> #include <unistd.h> #include <utmp.h> #include "pathnames.h" @@ -79,6 +81,7 @@ main(argc, argv) FILE *fp; off_t size; time_t t; + double delta; int ch; char *acctfile; @@ -140,11 +143,16 @@ main(argc, argv) continue; t = expand(ab.ac_utime) + expand(ab.ac_stime); - (void)printf("%-*.*s %-7s %-*.*s %-*.*s %6.2f secs %.16s\n", + (void)printf("%-*.*s %-7s %-*.*s %-*.*s %6.2f secs %.16s", fldsiz(acct, ac_comm), fldsiz(acct, ac_comm), ab.ac_comm, flagbits(ab.ac_flag), UT_NAMESIZE, UT_NAMESIZE, user_from_uid(ab.ac_uid, 0), UT_LINESIZE, UT_LINESIZE, getdev(ab.ac_tty), t / (double)AHZ, ctime(&ab.ac_btime)); + delta = expand(ab.ac_etime) / (double)AHZ; + printf(" (%1.0lf:%02.0lf:%05.2lf)\n", + delta / SECSPERHOUR, + fmod(delta, SECSPERHOUR) / SECSPERMIN, + fmod(delta, SECSPERMIN)); } exit(0); } |