Path: utzoo!attcan!uunet!lll-winken!ames!ncar!mailrus!cornell!uw-beaver!rice!sun-spots-request From: leres@helios.ee.lbl.gov (Craig Leres) Newsgroups: comp.sys.sun Subject: SunOS 4.0 /usr/ucb/w can't find console processes (pa Message-ID: <8901070522.AA24472@helios.ee.lbl.gov> Date: 14 Jan 89 02:27:09 GMT Sender: usenet@rice.edu Organization: Prime Computervision, Penn St, Amersham, England Lines: 80 Approved: Sun-Spots@rice.edu Original-Date: Fri, 06 Jan 89 21:22:51 PST X-Sun-Spots-Digest: Volume 7, Issue 102, message 18 of 18 I noticed that under 4.0, w never showed anything running on the console. I also noticed that ps worked correctly so I looked at its source and found some clever ifdef's with some interesting looking code. I incorporated these into w and they seem to do the trick. Appended are context diffs. Note that I've only tested this change on the sparc (but it ought to work on the 68k). Craig ------ diff -c w.c w.c.new *** w.c Fri Nov 11 21:36:49 1988 --- w.c.new Fri Jan 6 21:12:28 1989 *************** *** 11,17 **** #endif not lint #ifndef lint ! static char sccsid[] = "@(#)w.c 1.14 88/02/08 SMI"; /* from UCB 5.3 2/23/86 */ #endif not lint /* * w, uptime - print system status (who and what) --- 11,17 ---- #endif not lint #ifndef lint ! static char sccsid[] = "@(#)w.c 1.14++ 88/02/08 SMI"; /* from UCB 5.3 2/23/86 */ #endif not lint /* * w, uptime - print system status (who and what) *************** *** 57,62 **** --- 57,66 ---- #define X_BOOTTIME 1 { "_nproc" }, #define X_NPROC 2 + #ifdef sun + { "_rconsdev" }, + #define X_NRCONSDEV 3 + #endif { "" }, }; *************** *** 69,74 **** --- 73,81 ---- char doing[520]; /* process attached to terminal */ time_t proctime; /* cpu time of process in doing */ long avenrun[3]; + #ifdef sun + dev_t rconsdev; + #endif #define DIV60(t) ((t+30)/60) /* x/60 rounded */ #define TTYEQ (tty == pr[i].w_tty && (uid == 0 || uid == pr[i].w_uid)) *************** *** 431,436 **** --- 438,446 ---- * allocate proc table */ readsym(X_NPROC, &nproc, sizeof(nproc)); + #ifdef sun + readsym(X_NRCONSDEV, &rconsdev, sizeof (rconsdev)); + #endif pr = (struct pr *)calloc(nproc, sizeof (struct pr)); np = 0; while ((mproc = kvm_nextproc(kd)) != NULL) { *************** *** 455,460 **** --- 465,475 ---- up->u_ru.ru_utime.tv_sec + up->u_ru.ru_stime.tv_sec; pr[np].w_ctime = up->u_cru.ru_utime.tv_sec + up->u_cru.ru_stime.tv_sec; + #ifdef sun + if (up->u_ttyd == rconsdev) + up->u_ttyd = makedev(0, 0); /* "/dev/console" */ + + #endif pr[np].w_tty = up->u_ttyd; pr[np].w_uid = mproc->p_uid; strcpyn(pr[np].w_comm, up->u_comm, sizeof (pr->w_comm));