-
-walk(np)
- int np;
-{
- register int i, j, k, l, m;
-#undef afl
-#undef sfl
-#define afl(i,f) savcom[i].ap -> f
-#define sfl(i,f) savcom[i].sun.ssp -> f
-
- for(i = 0; i < np; i = j) {
- for(j = i; afl(j,a_ttyd) == afl(i,a_ttyd); j++) {
- sfl(j,ss_brother) = -1;
- sfl(j,ss_sons) = -1;
- }
- for(k = i+1; k < j; k++) {
- if(sfl(k,ss_ppid) == sfl(i,ss_ppid)) {
- for(l=i; sfl(l,ss_brother) != -1;
- l=sfl(l,ss_brother)) ;
- sfl(l,ss_brother) = k;
- goto next;
- }
- for(l = i; l < j; l++) {
- if(l == k) continue;
- if(sfl(k,ss_ppid) == afl(l,a_pid)) {
- if(sfl(l,ss_sons) == -1)
- sfl(l,ss_sons) = k;
- else {
- for(m = sfl(l,ss_sons);
- sfl(m,ss_brother) != -1;
- m = sfl(m,ss_brother)) ;
- sfl(m,ss_brother) = k;
- }
- goto next;
- }
- }
- for(l = i; l < j; l++) {
- if(l == k) continue;
- if(sfl(k,ss_ppid) == sfl(l,ss_ppid)) {
- for(m = k; sfl(m,ss_brother) != -1;
- m = sfl(m,ss_brother)) ;
- sfl(m,ss_brother) = l;
- }
- }
- next: ;
- }
- walk1(i, 0);
- }
-}
-
-walk1(pno, depth)
- int pno, depth;
-{
- if(pno == -1)
- return;
-/*** printf("%5d, %d\n",outargs[pno].o_pid, depth); ***/
- walkpr(&savcom[pno], depth);
- walk1(sfl(pno,ss_sons), depth+1);
- walk1(sfl(pno,ss_brother), depth);
-}
-
-char *sshdr =
-"TTY User SZ RSS CPU S PID ";
-
-walkpr(a, depth)
- register struct savcom *a;
- int depth;
-{
-
- if(!depth) {
- printf("%-2.2s", a->ap->a_tty);
- printf(" %-8.8s", getname(a->ap->a_uid));
- } else
- printf(" %-8s", &".......*"[8-(depth<=8?depth:8)]);
- printf("%4d%4d", a->ap->a_size/2, a->ap->a_rss/2);
- ptime(a->ap);
- /* Once there was a "CCPU" field here. Subsumed by -S now. */
- printf(" %4.4s", state(a->ap));
- printf("%6u ", a->ap->a_pid);
- if (a->ap->a_pid == 0)
- printf(" swapper");
- else if (a->ap->a_pid == 2)
- printf(" pagedaemon");
- else
- printf(" %.*s", twidth - cmdstart - 2, a->ap->a_cmdp);
- putchar('\n');
-}