From 753e31a4fe4747997918745c65b91b228bfef6fb Mon Sep 17 00:00:00 2001 From: mycroft Date: Thu, 25 May 1995 04:02:19 +0000 Subject: [PATCH] Don't core dump when tty has no associated process. --- usr.bin/w/w.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c index 699d00fd05d5..25d3cdbcb30d 100644 --- a/usr.bin/w/w.c +++ b/usr.bin/w/w.c @@ -317,15 +317,20 @@ pr_args(kp) char **argv; int left; + if (kp == 0) + goto nothing; left = argwidth; argv = kvm_getargv(kd, kp, argwidth); - if (argv) { - while (*argv) { - fmt_puts(*argv, &left); - argv++; - fmt_putc(' ', &left); - } + if (argv == 0) + goto nothing; + while (*argv) { + fmt_puts(*argv, &left); + argv++; + fmt_putc(' ', &left); } + return; +nothing: + putchar('-'); } static void