svn commit: r202199 - head/usr.bin/w
Ed Schouten
ed at FreeBSD.org
Wed Jan 13 18:09:21 UTC 2010
Author: ed
Date: Wed Jan 13 18:09:21 2010
New Revision: 202199
URL: http://svn.freebsd.org/changeset/base/202199
Log:
Port w(1) to utmpx.
Let it print "-" when the TTY string is empty. In this case, it must
also make sure it doesn't match processes who also have no controlling
TTY. Otherwise it will print random kernel processes when trying to pick
the best matching process.
Eventually it should look at the value of ut_pid as well.
Modified:
head/usr.bin/w/Makefile
head/usr.bin/w/w.c
Modified: head/usr.bin/w/Makefile
==============================================================================
--- head/usr.bin/w/Makefile Wed Jan 13 18:08:00 2010 (r202198)
+++ head/usr.bin/w/Makefile Wed Jan 13 18:09:21 2010 (r202199)
@@ -4,8 +4,8 @@
PROG= w
SRCS= fmt.c pr_time.c proc_compare.c w.c
MAN= w.1 uptime.1
-DPADD= ${LIBKVM} ${LIBULOG} ${LIBUTIL}
-LDADD= -lkvm -lulog -lutil
+DPADD= ${LIBKVM} ${LIBUTIL}
+LDADD= -lkvm -lutil
#BINGRP= kmem
#BINMODE=2555
LINKS= ${BINDIR}/w ${BINDIR}/uptime
Modified: head/usr.bin/w/w.c
==============================================================================
--- head/usr.bin/w/w.c Wed Jan 13 18:08:00 2010 (r202198)
+++ head/usr.bin/w/w.c Wed Jan 13 18:09:21 2010 (r202199)
@@ -83,9 +83,8 @@ static const char sccsid[] = "@(#)w.c 8.
#include <stdlib.h>
#include <string.h>
#include <timeconv.h>
-#define _ULOG_POSIX_NAMES
-#include <ulog.h>
#include <unistd.h>
+#include <utmpx.h>
#include <vis.h>
#include "extern.h"
@@ -283,7 +282,8 @@ main(int argc, char *argv[])
if ((kp = kvm_getprocs(kd, KERN_PROC_ALL, 0, &nentries)) == NULL)
err(1, "%s", kvm_geterr(kd));
for (i = 0; i < nentries; i++, kp++) {
- if (kp->ki_stat == SIDL || kp->ki_stat == SZOMB)
+ if (kp->ki_stat == SIDL || kp->ki_stat == SZOMB ||
+ kp->ki_tdev == NODEV)
continue;
for (ep = ehead; ep != NULL; ep = ep->next) {
if (ep->tdev == kp->ki_tdev) {
@@ -418,9 +418,10 @@ main(int argc, char *argv[])
(void)printf("%-*.*s %-*.*s %-*.*s ",
W_DISPUSERSIZE, W_DISPUSERSIZE, ep->utmp.ut_user,
W_DISPLINESIZE, W_DISPLINESIZE,
- strncmp(ep->utmp.ut_line, "tty", 3) &&
+ *ep->utmp.ut_line ?
+ (strncmp(ep->utmp.ut_line, "tty", 3) &&
strncmp(ep->utmp.ut_line, "cua", 3) ?
- ep->utmp.ut_line : ep->utmp.ut_line + 3,
+ ep->utmp.ut_line : ep->utmp.ut_line + 3) : "-",
W_DISPHOSTSIZE, W_DISPHOSTSIZE, *p ? p : "-");
t = ep->utmp.ut_tv.tv_sec;
longattime = pr_attime(&t, &now);
More information about the svn-src-all
mailing list