static char sccsid
[] = "@(#)lcmd2.c 3.11 %G%";
* Copyright (c) 1983 Regents of the University of California,
* All rights reserved. Redistribution permitted subject to
* the terms of the Berkeley Software License Agreement.
#include <sys/resource.h>
if ((w
= openiwin(14, "IO Statistics")) == 0) {
error("Can't open statistics window: %s.", wwerror());
wwprintf(w
, "ttflush\twrite\terror\tzero\tchar\n");
wwprintf(w
, "%d\t%d\t%d\t%d\t%d\n",
wwnflush
, wwnwr
, wwnwre
, wwnwrz
, wwnwrc
);
wwprintf(w
, "wwwrite\tattempt\tchar\n");
wwprintf(w
, "%d\t%d\t%d\n",
wwnwwr
, wwnwwra
, wwnwwrc
);
wwprintf(w
, "wwupdat\tline\tmiss\tmajor\tmiss\n");
wwprintf(w
, "%d\t%d\t%d\t%d\t%d\n",
wwnupdate
, wwnupdline
, wwnupdmiss
, wwnmajline
, wwnmajmiss
);
wwprintf(w
, "select\terror\tzero\n");
wwprintf(w
, "%d\t%d\t%d\n",
wwnselect
, wwnselecte
, wwnselectz
);
wwprintf(w
, "read\terror\tzero\tchar\n");
wwprintf(w
, "%d\t%d\t%d\t%d\n",
wwnread
, wwnreade
, wwnreadz
, wwnreadc
);
wwprintf(w
, "ptyread\terror\tzero\tcontrol\tdata\tchar\n");
wwprintf(w
, "%d\t%d\t%d\t%d\t%d\t%d\n",
wwnwread
, wwnwreade
, wwnwreadz
,
wwnwreadp
, wwnwreadd
, wwnwreadc
);
struct lcmd_arg arg_time
[] = {
register struct value
*a
;
if ((w
= openiwin(6, "Timing and Resource Usage")) == 0) {
error("Can't open time window: %s.", wwerror());
(void) gettimeofday(&timeval
, (struct timezone
*)0);
timeval
.tv_sec
-= starttime
.tv_sec
;
if ((timeval
.tv_usec
-= starttime
.tv_usec
) < 0) {
timeval
.tv_usec
+= 1000000;
(void) getrusage(a
->v_type
== V_STR
&& str_match(a
->v_str
, "children", 1)
? RUSAGE_CHILDREN
: RUSAGE_SELF
, &rusage
);
wwprintf(w
, "time\t\tutime\t\tstime\t\tmaxrss\tixrss\tidrss\tisrss\n");
wwprintf(w
, "%-16s", strtime(&timeval
));
wwprintf(w
, "%-16s", strtime(&rusage
.ru_utime
));
wwprintf(w
, "%-16s", strtime(&rusage
.ru_stime
));
wwprintf(w
, "%D\t%D\t%D\t%D\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\n");
wwprintf(w
, "%D\t%D\t%D\t%D\t%D\t%D\t%D\t%D\t%D\t%D\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
;
(void) sprintf(p
, "%D:", t
->tv_sec
/ (60*60));
(void) sprintf(p
, fill
? "%02D:" : "%D:", t
->tv_sec
/ 60);
(void) sprintf(p
, fill
? "%02D.%02d" : "%D.%02D",
t
->tv_sec
, t
->tv_usec
/ 10000);
register struct ww
*w
, *wp
;
for (n
= 0, i
= 0; i
< NWINDOW
; i
++)
if ((w
= openiwin(n
+ 2, "Windows")) == 0) {
error("Can't open listing window: %s.", wwerror());
for (i
= 0; i
< NWINDOW
; i
++) {
if ((wp
= window
[i
]) == 0)
wwprintf(w
, "%c %c %-13s %-.*s\n",
wp
== selwin
? '*' : ' ',
wp
->ww_state
== WWS_HASPROC
? "" : "(No process)",
wp
->ww_label
? wp
->ww_label
: "(No label)");
if ((w
= openiwin(wwnrow
- 3, "Variables")) == 0) {
error("Can't open variable window: %s.", wwerror());
if (var_walk(printvar
, (int)w
) >= 0)
wwprintf(w
, "%16s ", r
->r_name
);
switch (r
->r_val
.v_type
) {
wwprintf(w
, "%s\n", r
->r_val
.v_str
);
wwprintf(w
, "%d\n", r
->r_val
.v_num
);
struct lcmd_arg arg_shell
[] = {
{ "", 0, ARG_ANY
|ARG_LIST
},
register struct value
*vp
;
if (a
->v_type
== V_ERR
) {
if ((v
->v_str
= str_cpy(shellfile
)) != 0)
if (v
->v_str
= shellfile
) {
for (pp
= shell
+ 1; *pp
; pp
++) {
vp
->v_type
!= V_ERR
&& pp
< &shell
[sizeof shell
/sizeof *shell
-1];
if ((*pp
= vp
->v_type
== V_STR
?
str_cpy(vp
->v_str
) : str_itoa(vp
->v_num
)) == 0) {
/* just leave shell[] the way it is */
if (*shell
= rindex(shellfile
, '/'))
struct lcmd_arg arg_alias
[] = {
{ "", 0, ARG_STR
|ARG_LIST
},
if (a
->v_type
== V_ERR
) {
if ((w
= openiwin(wwnrow
- 3, "Aliases")) == 0) {
error("Can't open alias window: %s.", wwerror());
if (alias_walk(printalias
, (int)w
) >= 0)
register struct alias
*ap
= 0;
if (ap
= alias_lookup(a
->v_str
)) {
if ((v
->v_str
= str_cpy(ap
->a_buf
)) == 0) {
if (a
[1].v_type
== V_STR
) {
register struct value
*vp
;
for (n
= 0, vp
= a
+ 1; vp
->v_type
!= V_ERR
; vp
++, n
++)
for (p
= vp
->v_str
; *p
; p
++, n
++)
if ((str
= str_alloc(n
)) == 0) {
for (q
= str
, vp
= a
+ 1; vp
->v_type
!= V_ERR
;
for (p
= vp
->v_str
; *q
++ = *p
++;)
if ((ap
= alias_set(a
[0].v_str
, (char *)0)) == 0) {
register struct alias
*a
;
wwprintf(w
, "%16s %s\n", a
->a_name
, a
->a_buf
);
struct lcmd_arg arg_unalias
[] = {
if (a
->v_type
== ARG_STR
)
v
->v_num
= alias_unset(a
->v_str
);
struct lcmd_arg arg_echo
[] = {
{ "window", 1, ARG_NUM
},
{ "", 0, ARG_ANY
|ARG_LIST
},
register struct value
*a
;
if ((w
= vtowin(a
++, selwin
)) == 0)
while (a
->v_type
!= V_ERR
) {
if (a
->v_type
== V_NUM
) {
(void) sprintf(buf
, "%d", a
->v_num
);
(void) wwwrite(w
, buf
, strlen(buf
));
(void) wwwrite(w
, a
->v_str
, strlen(a
->v_str
));
if ((++a
)->v_type
!= V_ERR
)
(void) wwwrite(w
, " ", 1);
(void) wwwrite(w
, "\r\n", 2);