Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/systat * Fix a display buglet: if the process list i...
details: https://anonhg.NetBSD.org/src/rev/f59f168c6d61
branches: trunk
changeset: 479822:f59f168c6d61
user: kleink <kleink%NetBSD.org@localhost>
date: Wed Dec 22 14:46:14 1999 +0000
description:
* Fix a display buglet: if the process list is exhausted before the window's
bottom is reached, clear the remaining lines, lest there be stale process
entries if the process list shrinks.
* Implement a top(1)-like `user' command in the ps display.
diffstat:
usr.bin/systat/cmdtab.c | 11 ++++++++---
usr.bin/systat/extern.h | 3 ++-
usr.bin/systat/ps.c | 40 ++++++++++++++++++++++++++++++++++------
usr.bin/systat/systat.1 | 15 ++++++++++++++-
4 files changed, 58 insertions(+), 11 deletions(-)
diffs (168 lines):
diff -r 1e80f488b2ac -r f59f168c6d61 usr.bin/systat/cmdtab.c
--- a/usr.bin/systat/cmdtab.c Wed Dec 22 14:41:00 1999 +0000
+++ b/usr.bin/systat/cmdtab.c Wed Dec 22 14:46:14 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cmdtab.c,v 1.11 1999/12/20 03:45:02 jwise Exp $ */
+/* $NetBSD: cmdtab.c,v 1.12 1999/12/22 14:46:14 kleink Exp $ */
/*-
* Copyright (c) 1980, 1992, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)cmdtab.c 8.1 (Berkeley) 6/6/93";
#endif
-__RCSID("$NetBSD: cmdtab.c,v 1.11 1999/12/20 03:45:02 jwise Exp $");
+__RCSID("$NetBSD: cmdtab.c,v 1.12 1999/12/22 14:46:14 kleink Exp $");
#endif /* not lint */
#include "systat.h"
@@ -82,6 +82,11 @@
{ 0 }
};
+struct command ps_commands[] = {
+ { "user", ps_user, "limit displayed processes to a user"},
+ { 0 }
+};
+
struct command vmstat_commands[] = {
{ "boot", vmstat_boot, "show total vm stats since boot"},
{ "run", vmstat_run, "show running total vm stats"},
@@ -126,7 +131,7 @@
initnetstat, opennetstat, closenetstat, netstat_commands,
CF_LOADAV },
{ "ps", showps, fetchpigs, labelps,
- initpigs, openpigs, closepigs, 0,
+ initpigs, openpigs, closepigs, ps_commands,
CF_LOADAV },
{ "swap", showswap, fetchswap, labelswap,
initswap, openswap, closeswap, 0,
diff -r 1e80f488b2ac -r f59f168c6d61 usr.bin/systat/extern.h
--- a/usr.bin/systat/extern.h Wed Dec 22 14:41:00 1999 +0000
+++ b/usr.bin/systat/extern.h Wed Dec 22 14:46:14 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.16 1999/12/20 04:06:25 jwise Exp $ */
+/* $NetBSD: extern.h,v 1.17 1999/12/22 14:46:15 kleink Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -145,6 +145,7 @@
WINDOW *openpigs __P((void));
WINDOW *openswap __P((void));
WINDOW *opentcp __P((void));
+void ps_user __P((char *));
void redraw __P((int));
void showbufcache __P((void));
void showicmp __P((void));
diff -r 1e80f488b2ac -r f59f168c6d61 usr.bin/systat/ps.c
--- a/usr.bin/systat/ps.c Wed Dec 22 14:41:00 1999 +0000
+++ b/usr.bin/systat/ps.c Wed Dec 22 14:46:14 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ps.c,v 1.11 1999/12/20 19:31:47 jwise Exp $ */
+/* $NetBSD: ps.c,v 1.12 1999/12/22 14:46:15 kleink Exp $ */
/*-
* Copyright (c) 1999
@@ -45,7 +45,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: ps.c,v 1.11 1999/12/20 19:31:47 jwise Exp $");
+__RCSID("$NetBSD: ps.c,v 1.12 1999/12/22 14:46:15 kleink Exp $");
#endif /* not lint */
#include <sys/param.h>
@@ -80,6 +80,9 @@
static time_t now;
+#define SHOWUSER_ANY (uid_t)-1
+static uid_t showuser = SHOWUSER_ANY;
+
void
labelps ()
{
@@ -103,11 +106,13 @@
i = nproc + 1;
if (i > getmaxy(wnd)-2)
i = getmaxy(wnd)-1;
- for (k = 0; i > 0 ; i--, y++, k++) {
+ for (k = 0; i > 0 ; k++) {
if (pt[k].pt_kp == NULL) /* We're all the way down to the imaginary idle proc */
- return;
+ break;
ep = &pt[k].pt_kp->kp_eproc;
+ if (showuser != SHOWUSER_ANY && ep->e_ucred.cr_uid != showuser)
+ continue;
user = user_from_uid(ep->e_ucred.cr_uid, 0);
pid = pt[k].pt_kp->kp_proc.p_pid;
pctcpu = 100.0 * pt[k].pt_pctcpu;
@@ -123,9 +128,13 @@
wmove(wnd, y, 0);
wclrtoeol(wnd);
- mvwprintw(wnd, y, 0, "%-8.8s%5d %4.1f %4.1f %6d %5d %-3s %-4s %7s %10.10s %s",
- user, pid, pctcpu, pctmem, vsz, rss, tty, state, start, time, comm);
+ mvwprintw(wnd, y++, 0,
+ "%-8.8s%5d %4.1f %4.1f %6d %5d %-3s %-4s %7s %10.10s %s",
+ user, pid, pctcpu, pctmem, vsz, rss, tty, state, start, time, comm);
+ i--;
}
+ wmove(wnd, y, 0);
+ wclrtobot(wnd);
}
int
@@ -384,3 +393,22 @@
return timestr;
}
+
+void
+ps_user(args)
+ char *args;
+{
+ uid_t uid;
+
+ if (args == NULL)
+ args = "";
+ if (strcmp(args, "+") == 0) {
+ uid = SHOWUSER_ANY;
+ } else if (uid_from_user(args, &uid) != 0) {
+ error("%s: unknown user", args);
+ return;
+ }
+
+ showuser = uid;
+ display(0);
+}
diff -r 1e80f488b2ac -r f59f168c6d61 usr.bin/systat/systat.1
--- a/usr.bin/systat/systat.1 Wed Dec 22 14:41:00 1999 +0000
+++ b/usr.bin/systat/systat.1 Wed Dec 22 14:46:14 1999 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: systat.1,v 1.16 1999/11/15 06:16:57 simonb Exp $
+.\" $NetBSD: systat.1,v 1.17 1999/12/22 14:46:15 kleink Exp $
.\"
.\" Copyright (c) 1985, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -281,6 +281,19 @@
.Xr ps 1
with the flags
.Fl aux .
+.Pp
+The following command is specific to the
+.Ic ps
+display; the minimum unambiguous prefix may be supplied.
+.Pp
+.Bl -tag -width Fl -compact
+.It Cm user Ar name
+Limit the list of processes displayed to those owned by user
+.Ar name .
+If
+.Ar name
+is specified as `+', processes owned by any user are displayed (default).
+.El
.It Ic swap
Show information about swap space usage on all the
swap areas configured with
Home |
Main Index |
Thread Index |
Old Index