Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/ps provide a tree like display with -d, from FreeBSD
details: https://anonhg.NetBSD.org/src/rev/38829bb2870e
branches: trunk
changeset: 349264:38829bb2870e
user: christos <christos%NetBSD.org@localhost>
date: Fri Dec 02 21:59:03 2016 +0000
description:
provide a tree like display with -d, from FreeBSD
diffstat:
bin/ps/extern.h | 78 ++++++++++----------
bin/ps/print.c | 199 ++++++++++++++++++++++++-------------------------------
bin/ps/ps.1 | 15 +++-
bin/ps/ps.c | 137 ++++++++++++++++++++++++++++++++++++--
bin/ps/ps.h | 27 +++---
5 files changed, 281 insertions(+), 175 deletions(-)
diffs (truncated from 1012 to 300 lines):
diff -r 18be5f59248e -r 38829bb2870e bin/ps/extern.h
--- a/bin/ps/extern.h Fri Dec 02 20:53:36 2016 +0000
+++ b/bin/ps/extern.h Fri Dec 02 21:59:03 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.37 2016/11/28 08:21:10 rin Exp $ */
+/* $NetBSD: extern.h,v 1.38 2016/12/02 21:59:03 christos Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -46,54 +46,54 @@
extern VARLIST displaylist;
extern VARLIST sortlist;
-void command(void *, VARENT *, enum mode);
-void cpuid(void *, VARENT *, enum mode);
-void cputime(void *, VARENT *, enum mode);
+void command(struct pinfo *, VARENT *, enum mode);
+void cpuid(struct pinfo *, VARENT *, enum mode);
+void cputime(struct pinfo *, VARENT *, enum mode);
void donlist(void);
void donlist_sysctl(void);
void fmt_puts(char *, int *);
void fmt_putc(int, int *);
-void elapsed(void *, VARENT *, enum mode);
+void elapsed(struct pinfo *, VARENT *, enum mode);
double getpcpu(const struct kinfo_proc2 *);
double getpmem(const struct kinfo_proc2 *);
-void gname(void *, VARENT *, enum mode);
-void groups(void *, VARENT *, enum mode);
-void groupnames(void *, VARENT *, enum mode);
-void lcputime(void *, VARENT *, enum mode);
-void logname(void *, VARENT *, enum mode);
-void longtname(void *, VARENT *, enum mode);
-void lname(void *, VARENT *, enum mode);
-void lstarted(void *, VARENT *, enum mode);
-void lstate(void *, VARENT *, enum mode);
-void maxrss(void *, VARENT *, enum mode);
+void gname(struct pinfo *, VARENT *, enum mode);
+void groups(struct pinfo *, VARENT *, enum mode);
+void groupnames(struct pinfo *, VARENT *, enum mode);
+void lcputime(struct pinfo *, VARENT *, enum mode);
+void logname(struct pinfo *, VARENT *, enum mode);
+void longtname(struct pinfo *, VARENT *, enum mode);
+void lname(struct pinfo *, VARENT *, enum mode);
+void lstarted(struct pinfo *, VARENT *, enum mode);
+void lstate(struct pinfo *, VARENT *, enum mode);
+void maxrss(struct pinfo *, VARENT *, enum mode);
void nlisterr(struct nlist *);
-void p_rssize(void *, VARENT *, enum mode);
-void pagein(void *, VARENT *, enum mode);
+void p_rssize(struct pinfo *, VARENT *, enum mode);
+void pagein(struct pinfo *, VARENT *, enum mode);
void parsefmt(const char *);
void parsefmt_insert(const char *, VARENT **);
void parsesort(const char *);
VARENT * varlist_find(VARLIST *, const char *);
-void emul(void *, VARENT *, enum mode);
-void pcpu(void *, VARENT *, enum mode);
-void pmem(void *, VARENT *, enum mode);
-void pnice(void *, VARENT *, enum mode);
-void pri(void *, VARENT *, enum mode);
+void emul(struct pinfo *, VARENT *, enum mode);
+void pcpu(struct pinfo *, VARENT *, enum mode);
+void pmem(struct pinfo *, VARENT *, enum mode);
+void pnice(struct pinfo *, VARENT *, enum mode);
+void pri(struct pinfo *, VARENT *, enum mode);
void printheader(void);
-void putimeval(void *, VARENT *, enum mode);
-void pvar(void *, VARENT *, enum mode);
-void rgname(void *, VARENT *, enum mode);
-void rssize(void *, VARENT *, enum mode);
-void runame(void *, VARENT *, enum mode);
+void putimeval(struct pinfo *, VARENT *, enum mode);
+void pvar(struct pinfo *, VARENT *, enum mode);
+void rgname(struct pinfo *, VARENT *, enum mode);
+void rssize(struct pinfo *, VARENT *, enum mode);
+void runame(struct pinfo *, VARENT *, enum mode);
void showkey(void);
-void started(void *, VARENT *, enum mode);
-void state(void *, VARENT *, enum mode);
-void svgname(void *, VARENT *, enum mode);
-void svuname(void *, VARENT *, enum mode);
-void tdev(void *, VARENT *, enum mode);
-void tname(void *, VARENT *, enum mode);
-void tsize(void *, VARENT *, enum mode);
-void ucomm(void *, VARENT *, enum mode);
-void uname(void *, VARENT *, enum mode);
-void uvar(void *, VARENT *, enum mode);
-void vsize(void *, VARENT *, enum mode);
-void wchan(void *, VARENT *, enum mode);
+void started(struct pinfo *, VARENT *, enum mode);
+void state(struct pinfo *, VARENT *, enum mode);
+void svgname(struct pinfo *, VARENT *, enum mode);
+void svuname(struct pinfo *, VARENT *, enum mode);
+void tdev(struct pinfo *, VARENT *, enum mode);
+void tname(struct pinfo *, VARENT *, enum mode);
+void tsize(struct pinfo *, VARENT *, enum mode);
+void ucomm(struct pinfo *, VARENT *, enum mode);
+void uname(struct pinfo *, VARENT *, enum mode);
+void uvar(struct pinfo *, VARENT *, enum mode);
+void vsize(struct pinfo *, VARENT *, enum mode);
+void wchan(struct pinfo *, VARENT *, enum mode);
diff -r 18be5f59248e -r 38829bb2870e bin/ps/print.c
--- a/bin/ps/print.c Fri Dec 02 20:53:36 2016 +0000
+++ b/bin/ps/print.c Fri Dec 02 21:59:03 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: print.c,v 1.125 2016/11/28 08:21:10 rin Exp $ */
+/* $NetBSD: print.c,v 1.126 2016/12/02 21:59:03 christos Exp $ */
/*
* Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
#if 0
static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94";
#else
-__RCSID("$NetBSD: print.c,v 1.125 2016/11/28 08:21:10 rin Exp $");
+__RCSID("$NetBSD: print.c,v 1.126 2016/12/02 21:59:03 christos Exp $");
#endif
#endif /* not lint */
@@ -278,9 +278,9 @@
}
void
-command(void *arg, VARENT *ve, enum mode mode)
+command(struct pinfo *pi, VARENT *ve, enum mode mode)
{
- struct kinfo_proc2 *ki;
+ struct kinfo_proc2 *ki = pi->ki;
VAR *v;
int left;
char **argv, **p, *name;
@@ -288,7 +288,6 @@
if (mode == WIDTHMODE)
return;
- ki = arg;
v = ve->var;
if (SIMPLEQ_NEXT(ve, next) != NULL || termwidth != UNLIMITED) {
if (SIMPLEQ_NEXT(ve, next) == NULL) {
@@ -310,6 +309,8 @@
}
}
if (needcomm) {
+ if (pi->prefix)
+ (void)fmt_puts(pi->prefix, &left);
name = ki->p_comm;
if (!commandonly) {
argv = kvm_getargv2(kd, ki, termwidth);
@@ -359,9 +360,9 @@
}
void
-groups(void *arg, VARENT *ve, enum mode mode)
+groups(struct pinfo *pi, VARENT *ve, enum mode mode)
{
- struct kinfo_proc2 *ki;
+ struct kinfo_proc2 *ki = pi->ki;
VAR *v;
int left, i;
char buf[16], *p;
@@ -369,7 +370,6 @@
if (mode == WIDTHMODE)
return;
- ki = arg;
v = ve->var;
if (SIMPLEQ_NEXT(ve, next) != NULL || termwidth != UNLIMITED) {
if (SIMPLEQ_NEXT(ve, next) == NULL) {
@@ -397,9 +397,9 @@
}
void
-groupnames(void *arg, VARENT *ve, enum mode mode)
+groupnames(struct pinfo *pi, VARENT *ve, enum mode mode)
{
- struct kinfo_proc2 *ki;
+ struct kinfo_proc2 *ki = pi->ki;
VAR *v;
int left, i;
const char *p;
@@ -407,7 +407,6 @@
if (mode == WIDTHMODE)
return;
- ki = arg;
v = ve->var;
if (SIMPLEQ_NEXT(ve, next) != NULL || termwidth != UNLIMITED) {
if (SIMPLEQ_NEXT(ve, next) == NULL) {
@@ -434,48 +433,49 @@
}
void
-ucomm(void *arg, VARENT *ve, enum mode mode)
+ucomm(struct pinfo *pi, VARENT *ve, enum mode mode)
{
- struct kinfo_proc2 *k;
+ struct kinfo_proc2 *k = pi->ki;
+ char buf[MAXPATHLEN], *p;
VAR *v;
- k = arg;
v = ve->var;
- strprintorsetwidth(v, k->p_comm, mode);
+ if (pi->prefix)
+ snprintf(p = buf, sizeof(buf), "%s%s", pi->prefix, k->p_comm);
+ else
+ p = k->p_comm;
+ strprintorsetwidth(v, p, mode);
}
void
-emul(void *arg, VARENT *ve, enum mode mode)
+emul(struct pinfo *pi, VARENT *ve, enum mode mode)
{
- struct kinfo_proc2 *k;
+ struct kinfo_proc2 *k = pi->ki;
VAR *v;
- k = arg;
v = ve->var;
strprintorsetwidth(v, k->p_ename, mode);
}
void
-logname(void *arg, VARENT *ve, enum mode mode)
+logname(struct pinfo *pi, VARENT *ve, enum mode mode)
{
- struct kinfo_proc2 *k;
+ struct kinfo_proc2 *k = pi->ki;
VAR *v;
- k = arg;
v = ve->var;
strprintorsetwidth(v, k->p_login, mode);
}
void
-state(void *arg, VARENT *ve, enum mode mode)
+state(struct pinfo *pi, VARENT *ve, enum mode mode)
{
- struct kinfo_proc2 *k;
+ struct kinfo_proc2 *k = pi->ki;
int flag, is_zombie;
char *cp;
VAR *v;
char buf[16];
- k = arg;
is_zombie = 0;
v = ve->var;
flag = k->p_flag;
@@ -551,15 +551,14 @@
}
void
-lstate(void *arg, VARENT *ve, enum mode mode)
+lstate(struct pinfo *pi, VARENT *ve, enum mode mode)
{
- struct kinfo_lwp *k;
+ struct kinfo_lwp *k = pi->li;
int flag;
char *cp;
VAR *v;
char buf[16];
- k = arg;
v = ve->var;
flag = k->l_flag;
cp = buf;
@@ -610,102 +609,93 @@
}
void
-pnice(void *arg, VARENT *ve, enum mode mode)
+pnice(struct pinfo *pi, VARENT *ve, enum mode mode)
{
- struct kinfo_proc2 *k;
+ struct kinfo_proc2 *k = pi->ki;
VAR *v;
- k = arg;
v = ve->var;
intprintorsetwidth(v, k->p_nice - NZERO, mode);
}
void
-pri(void *arg, VARENT *ve, enum mode mode)
+pri(struct pinfo *pi, VARENT *ve, enum mode mode)
{
- struct kinfo_lwp *l;
+ struct kinfo_lwp *l = pi->li;
VAR *v;
- l = arg;
v = ve->var;
intprintorsetwidth(v, l->l_priority, mode);
}
void
Home |
Main Index |
Thread Index |
Old Index