summary |
tags |
clone url |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
010af04)
SCCS-vsn: bin/csh/csh.c 4.10
SCCS-vsn: bin/csh/csh.h 4.6
SCCS-vsn: bin/csh/proc.c 4.8
SCCS-vsn: bin/csh/proc.h 4.3
SCCS-vsn: bin/csh/time.c 4.3
-static char *sccsid = "@(#)csh.c 4.9 %G%";
+static char *sccsid = "@(#)csh.c 4.10 %G%";
#include "sh.h"
#include <sys/ioctl.h>
#include "sh.h"
#include <sys/ioctl.h>
for (; *vp; vp++) {
if (stat(*vp, &stb) < 0)
continue;
for (; *vp; vp++) {
if (stat(*vp, &stb) < 0)
continue;
- new = stb.st_mtime > time0;
+ new = stb.st_mtime > time0.tv_sec;
if (stb.st_size == 0 || stb.st_atime > stb.st_mtime ||
(stb.st_atime < chktim && stb.st_mtime < chktim) ||
loginsh && !new)
if (stb.st_size == 0 || stb.st_atime > stb.st_mtime ||
(stb.st_atime < chktim && stb.st_mtime < chktim) ||
loginsh && !new)
-/* csh.h 4.5 82/12/30 */
+/* csh.h 4.6 83/02/03 */
#include "sh.local.h"
#include <time.h>
#include "sh.local.h"
#include <time.h>
char *err; /* Error message from scanner/parser */
int errno; /* Error from C library routines */
char *shtemp; /* Temp name for << shell files in /tmp */
char *err; /* Error message from scanner/parser */
int errno; /* Error from C library routines */
char *shtemp; /* Temp name for << shell files in /tmp */
-time_t time0; /* Time at which the shell started */
+struct timeval time0; /* Time at which the shell started */
-static char *sccsid = "@(#)proc.c 4.7 (Berkeley) 82/12/30";
+static char *sccsid = "@(#)proc.c 4.8 (Berkeley) 83/02/03";
#include "sh.h"
#include "sh.dir.h"
#include "sh.h"
#include "sh.dir.h"
time_t oldcutimes, oldcstimes;
oldcutimes = shtimes.tms_cutime;
oldcstimes = shtimes.tms_cstime;
time_t oldcutimes, oldcstimes;
oldcutimes = shtimes.tms_cutime;
oldcstimes = shtimes.tms_cstime;
+ gettimeofday(&pp->p_etime, (struct timezone *)0);
times(&shtimes);
pp->p_utime = shtimes.tms_cutime - oldcutimes;
pp->p_stime = shtimes.tms_cstime - oldcstimes;
times(&shtimes);
pp->p_utime = shtimes.tms_cutime - oldcutimes;
pp->p_stime = shtimes.tms_cstime - oldcstimes;
}
pp->p_next = proclist.p_next;
proclist.p_next = pp;
}
pp->p_next = proclist.p_next;
proclist.p_next = pp;
+ gettimeofday(&pp->p_btime, (struct timezone *)0);
if (linp != linbuf)
printf("\n\t");
{ static struct rusage zru;
if (linp != linbuf)
printf("\n\t");
{ static struct rusage zru;
- prusage(&zru, &pp->p_rusage,
- pp->p_etime - pp->p_btime);
+ prusage(&zru, &pp->p_rusage, &pp->p_etime,
+ &pp->p_btime);
}
}
if (tp == pp->p_friends) {
}
}
if (tp == pp->p_friends) {
ptprint(tp)
register struct process *tp;
{
ptprint(tp)
register struct process *tp;
{
+ struct timeval tetime, diff;
+ static struct timeval ztime;
struct rusage ru;
static struct rusage zru;
register struct process *pp = tp;
ru = zru;
struct rusage ru;
static struct rusage zru;
register struct process *pp = tp;
ru = zru;
do {
ruadd(&ru, &pp->p_rusage);
do {
ruadd(&ru, &pp->p_rusage);
- if (pp->p_etime - pp->p_btime > tetime)
- tetime = pp->p_etime - pp->p_btime;
+ tvsub(&diff, &pp->p_etime, &pp->p_btime);
+ if (timercmp(&diff, &tetime, >))
+ tetime = diff;
} while ((pp = pp->p_friends) != tp);
} while ((pp = pp->p_friends) != tp);
- prusage(&zru, &ru, tetime);
+ prusage(&zru, &ru, &tetime, &ztime);
/*
* C shell - process structure declarations
/*
* C shell - process structure declarations
short p_pid;
short p_jobid; /* pid of job leader */
/* if a job is stopped/background p_jobid gives its pgrp */
short p_pid;
short p_jobid; /* pid of job leader */
/* if a job is stopped/background p_jobid gives its pgrp */
- time_t p_btime; /* begin time */
- time_t p_etime; /* end time */
- long p_stime; /* system cpu time */
- long p_utime; /* user cpu time */
+ struct timeval p_btime; /* begin time */
+ struct timeval p_etime; /* end time */
+ long p_utime; /* XXX */
+ long p_stime; /* XXX */
char *p_command; /* first PMAXLEN chars of command */
};
char *p_command; /* first PMAXLEN chars of command */
};
-/* time.c 4.2 82/12/30 */
+/* time.c 4.3 83/02/03 */
+ gettimeofday(&time0, (struct timezone *)0);
getrusage(RUSAGE_SELF, &ru0);
getrusage(RUSAGE_CHILDREN, &ruch);
ruadd(&ru0, &ruch);
getrusage(RUSAGE_SELF, &ru0);
getrusage(RUSAGE_CHILDREN, &ruch);
ruadd(&ru0, &ruch);
+ struct timeval timedol;
struct rusage ru1, ruch;
getrusage(RUSAGE_SELF, &ru1);
getrusage(RUSAGE_CHILDREN, &ruch);
ruadd(&ru1, &ruch);
struct rusage ru1, ruch;
getrusage(RUSAGE_SELF, &ru1);
getrusage(RUSAGE_CHILDREN, &ruch);
ruadd(&ru1, &ruch);
- time(&timedol);
- prusage(&ru0, &ru1, timedol - time0);
+ gettimeofday(&timedol, (struct timezone *)0);
+ prusage(&ru0, &ru1, &timedol, &time0);
register struct rusage *r0, *r1;
register struct rusage *r0, *r1;
{
register time_t t =
(r1->ru_utime.tv_sec-r0->ru_utime.tv_sec)*100+
{
register time_t t =
(r1->ru_utime.tv_sec-r0->ru_utime.tv_sec)*100+
register char *cp;
register int i;
register struct varent *vp = adrof("time");
register char *cp;
register int i;
register struct varent *vp = adrof("time");
+ int ms =
+ (e->tv_sec-b->tv_sec)*100 + (e->tv_usec-b->tv_usec)/10000;
cp = "%Uu %Ss %E %P %X+%Dk %I+%Oio %Fpf+%Ww";
if (vp && vp->vec[0] && vp->vec[1])
cp = "%Uu %Ss %E %P %X+%Dk %I+%Oio %Fpf+%Ww";
if (vp && vp->vec[0] && vp->vec[1])
- printf("%d%%", (int) (t / ((sec ? sec : 1))));
+ printf("%d%%", (int) (t*100 / ((ms ? ms : 1))));