Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/w Revert previous commit. I forgot we already do tha...
details: https://anonhg.NetBSD.org/src/rev/dbc26cb6fdf8
branches: trunk
changeset: 584014:dbc26cb6fdf8
user: elad <elad%NetBSD.org@localhost>
date: Sun Sep 04 21:18:33 2005 +0000
description:
Revert previous commit. I forgot we already do that. :)
diffstat:
usr.bin/w/w.c | 97 +++++++---------------------------------------------------
1 files changed, 13 insertions(+), 84 deletions(-)
diffs (147 lines):
diff -r 7ca08fcba78b -r dbc26cb6fdf8 usr.bin/w/w.c
--- a/usr.bin/w/w.c Sun Sep 04 19:44:09 2005 +0000
+++ b/usr.bin/w/w.c Sun Sep 04 21:18:33 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: w.c,v 1.69 2005/09/04 19:02:08 elad Exp $ */
+/* $NetBSD: w.c,v 1.70 2005/09/04 21:18:33 elad Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993, 1994
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)w.c 8.6 (Berkeley) 6/30/94";
#else
-__RCSID("$NetBSD: w.c,v 1.69 2005/09/04 19:02:08 elad Exp $");
+__RCSID("$NetBSD: w.c,v 1.70 2005/09/04 21:18:33 elad Exp $");
#endif
#endif /* not lint */
@@ -101,7 +101,6 @@
char *sel_user; /* login of particular user selected */
char domain[MAXHOSTNAMELEN + 1];
int maxname = 8, maxline = 3, maxhost = 16;
-int use_sysctl;
/*
* One of these per active utmp entry.
@@ -191,13 +190,9 @@
argc -= optind;
argv += optind;
- use_sysctl = (memf == NULL && nlistf == NULL);
-
- if (!use_sysctl) {
- if ((kd = kvm_openfiles(nlistf, memf, NULL,
- memf == NULL ? KVM_NO_FILES : O_RDONLY, errbuf)) == NULL)
- errx(1, "%s", errbuf);
- }
+ if ((kd = kvm_openfiles(nlistf, memf, NULL,
+ memf == NULL ? KVM_NO_FILES : O_RDONLY, errbuf)) == NULL)
+ errx(1, "%s", errbuf);
(void)time(&now);
@@ -291,28 +286,9 @@
exit (0);
}
- if (use_sysctl) {
- int mib[6] = { CTL_KERN, KERN_PROC2, KERN_PROC_ALL, 0, sizeof(*kp), 0 };
- size_t size;
-
- if (sysctl(mib, 6, NULL, &size, NULL, 0) == -1)
- err(1, "sysctl (query)");
-
- if ((kp = malloc(size)) == NULL)
- err(1, "malloc");
- memset(kp, 0, size);
-
- mib[5] = size / sizeof(*kp);
-
- if (sysctl(mib, 6, kp, &size, NULL, 0) == -1)
- err(1, "sysctl (copy)");
-
- nentries = size / sizeof(*kp);
- } else {
- if ((kp = kvm_getproc2(kd, KERN_PROC_ALL, 0,
- sizeof(struct kinfo_proc2), &nentries)) == NULL)
- errx(1, "%s", kvm_geterr(kd));
- }
+ if ((kp = kvm_getproc2(kd, KERN_PROC_ALL, 0,
+ sizeof(struct kinfo_proc2), &nentries)) == NULL)
+ errx(1, "%s", kvm_geterr(kd));
/* Include trailing space because TTY header starts one column early. */
for (i = 0; i < nentries; i++, kp++) {
@@ -463,48 +439,7 @@
if (kp == 0)
goto nothing;
left = argwidth;
-
- if (use_sysctl) {
- char *a = NULL;
- size_t size;
- int mib[4] = { CTL_KERN, KERN_PROC_ARGS, kp->p_pid, KERN_PROC_NARGV };
- int nargv;
-
- size = sizeof(nargv);
- if (sysctl(mib, 4, &nargv, &size, NULL, 0) == -1)
- err(1, "sysctl (nargv)");
-
- size = ARG_MAX;
-
- argv = malloc(size);
- memset(argv, 0, size);
-
- mib[3] = KERN_PROC_ARGV;
-
- if (sysctl(mib, 4, argv, &size, NULL, 0) == -1)
- err(1, "sysctl (argv copy)");
-
- if (size == 0) {
- free(argv);
- argv = NULL;
- }
-
- if (nargv != 1 && argv != NULL) {
- a = (char *)argv;
- while (nargv > 1) {
- if (*a == '\0') {
- *a = ' ';
- nargv--;
- }
- a++;
- }
- }
- if (a != NULL && argwidth)
- argv[argwidth] = '\0';
- } else {
- argv = kvm_getargv2(kd, kp, (argwidth < 0) ? 0 : argwidth);
- }
-
+ argv = kvm_getargv2(kd, kp, (argwidth < 0) ? 0 : argwidth);
if (argv == 0) {
if (kp->p_comm == 0) {
goto nothing;
@@ -515,17 +450,11 @@
return;
}
}
-
- if (use_sysctl) {
- printf("%s", (char *)argv);
- } else {
- while (*argv) {
- fmt_puts(*argv, &left);
- argv++;
- fmt_putc(' ', &left);
- }
+ while (*argv) {
+ fmt_puts(*argv, &left);
+ argv++;
+ fmt_putc(' ', &left);
}
-
return;
nothing:
putchar('-');
Home |
Main Index |
Thread Index |
Old Index