static char *sccsid
= "@(#)main.c 1.2 83/07/17";
#include <sys/resource.h>
struct timeval starttime
;
struct timezone timezone
;
fprintf("Can't do windows on this terminal.\n");
if ((w1
= wwopen(1, n
, WCols
, 0, 0)) == 0
|| (w2
= wwopen(2, WRows
- n
, WCols
, n
, 0)) == 0) {
fprintf(stderr
, "Can't open windows.\n");
(void) signal(SIGCHLD
, wwchild
);
execl("/bin/csh", "csh", 0);
perror("execl(/bin/csh)");
execl("/bin/csh", "csh", 0);
perror("execl(/bin/csh)");
gettimeofday(&starttime
, &timezone
);
wwputstr("Type ^P? for help.\r\n");
while (imask
= 1<<0, wwforce(&imask
) < 0)
n
= read(0, buf
, sizeof buf
);
for (p
= buf
; n
-- > 0; p
++) {
write(curwin
->ww_pty
, p
, 1);
write(curwin
->ww_pty
, p
, 1);
wwprintf(curwin
, "\r\nread: %d, write: %d\r\n",
printrusage(curwin
, RUSAGE_SELF
);
printrusage(curwin
, RUSAGE_CHILDREN
);
write(curwin
->ww_pty
, &c
, 1);
write(curwin
->ww_pty
, p
, 1);
wwputstr("^P1 goto top window\r\n");
wwputstr("^P2 goto bottom window\r\n");
wwputstr("^PR force refresh after every newline\r\n");
wwputstr("^Pr don't refresh every line\r\n");
wwputstr("^Ps print io statistics\r\n");
wwputstr("^Pt print resource usage of this program\r\n");
wwputstr("^PT print resource usage of children\r\n");
wwputstr("^P^L redraw screen\r\n");
wwputstr("^P^Z suspend\r\n");
wwputstr("^P. quit\r\n");
gettimeofday(&timeval
, &timezone
);
timeval
.tv_sec
-= starttime
.tv_sec
;
if ((timeval
.tv_usec
-= starttime
.tv_usec
) < 0) {
timeval
.tv_usec
+= 1000000;
getrusage(flag
, &rusage
);
wwprintf(w
, "\r\ntime\t\tutime\tstime\tmaxrss\tixrss\tidrss\tisrss\r\n");
wwprintf(w
, "%-16s", strtime(&timeval
));
wwprintf(w
, "%-8s", strtime(&rusage
.ru_utime
));
wwprintf(w
, "%-8s", strtime(&rusage
.ru_stime
));
wwprintf(w
, "%D\t%D\t%D\t%D\r\n",
rusage
.ru_maxrss
, rusage
.ru_ixrss
,
rusage
.ru_idrss
, rusage
.ru_isrss
);
wwprintf(w
, "minflt\tmajflt\tnswap\tinblk\toublk\tmsgsnd\tmsgrcv\tnsigs\tnvcsw\tnivcsw\r\n");
wwprintf(w
, "%D\%D\t%D\t%D\t%D\t%D\t%D\t%D\t%D\t%D\t%D\r\n",
rusage
.ru_minflt
, rusage
.ru_majflt
, rusage
.ru_nswap
,
rusage
.ru_inblock
, rusage
.ru_oublock
,
rusage
.ru_msgsnd
, rusage
.ru_msgrcv
, rusage
.ru_nsignals
,
rusage
.ru_nvcsw
, rusage
.ru_nivcsw
);
register struct timeval
*t
;
sprintf(p
, "%D:", t
->tv_sec
/ 60*60);
sprintf(p
, fill
? "%02D:" : "%D:", t
->tv_sec
/ 60, ':');
sprintf(p
, fill
? "%02D.%02d" : "%D.%02D",
t
->tv_sec
, t
->tv_usec
/ 10000);