summaryrefslogtreecommitdiff
path: root/usr.bin/w
diff options
context:
space:
mode:
authorJason Downs <downsj@cvs.openbsd.org>1996-08-22 02:12:34 +0000
committerJason Downs <downsj@cvs.openbsd.org>1996-08-22 02:12:34 +0000
commitce8fe8119d04358767d7fc080c31019a7c5623ed (patch)
tree59254a3f29af1914608a76701b2c7f2be2fbf465 /usr.bin/w
parent19be98c3f0e2ed926db0a2e72939653859ebc3ea (diff)
Handle ftp entries better.
Diffstat (limited to 'usr.bin/w')
-rw-r--r--usr.bin/w/w.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c
index ca553004915..1284f06159b 100644
--- a/usr.bin/w/w.c
+++ b/usr.bin/w/w.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: w.c,v 1.6 1996/08/12 02:28:43 deraadt Exp $ */
+/* $OpenBSD: w.c,v 1.7 1996/08/22 02:12:33 downsj Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993, 1994
@@ -241,7 +241,17 @@ main(argc, argv)
continue;
e = &kp->kp_eproc;
for (ep = ehead; ep != NULL; ep = ep->next) {
- if (ep->tdev == e->e_tdev && e->e_pgid == e->e_tpgid) {
+ /* ftp is a special case. */
+ if (strncmp(ep->utmp.ut_line, "ftp", 3) == 0) {
+ pid_t fp = (pid_t)strtol(&ep->utmp.ut_line[3],
+ NULL, 10);
+ if (p->p_pid == fp) {
+ ep->kp = kp;
+
+ break;
+ }
+ } else if (ep->tdev == e->e_tdev
+ && e->e_pgid == e->e_tpgid) {
/*
* Proc is in foreground of this terminal
*/
@@ -324,7 +334,7 @@ static void
pr_args(kp)
struct kinfo_proc *kp;
{
- char **argv;
+ char **argv, *str;
int left;
if (kp == 0)
@@ -333,8 +343,19 @@ pr_args(kp)
argv = kvm_getargv(kd, kp, argwidth);
if (argv == 0)
goto nothing;
+
while (*argv) {
- fmt_puts(*argv, &left);
+ /* ftp is a special case... */
+ if (strncmp(*argv, "ftpd:", 5) == 0) {
+ str = strrchr(*argv, ':');
+ if (str != (char *)NULL) {
+ if (strlen(str) > 2)
+ str += 2;
+ fmt_puts(str, &left);
+ } else
+ fmt_puts(*argv, &left);
+ } else
+ fmt_puts(*argv, &left);
argv++;
fmt_putc(' ', &left);
}