[Midnightbsd-cvs] src [11188] trunk/bin/ps: change exit
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Jun 30 19:45:14 EDT 2018
Revision: 11188
http://svnweb.midnightbsd.org/src/?rev=11188
Author: laffer1
Date: 2018-06-30 19:45:13 -0400 (Sat, 30 Jun 2018)
Log Message:
-----------
change exit
Modified Paths:
--------------
trunk/bin/ps/Makefile
trunk/bin/ps/extern.h
trunk/bin/ps/fmt.c
trunk/bin/ps/keyword.c
trunk/bin/ps/nlist.c
trunk/bin/ps/print.c
trunk/bin/ps/ps.1
trunk/bin/ps/ps.c
trunk/bin/ps/ps.h
Property Changed:
----------------
trunk/bin/ps/ps.1
Modified: trunk/bin/ps/Makefile
===================================================================
--- trunk/bin/ps/Makefile 2018-06-30 23:44:18 UTC (rev 11187)
+++ trunk/bin/ps/Makefile 2018-06-30 23:45:13 UTC (rev 11188)
@@ -1,5 +1,5 @@
# $MidnightBSD$
-# $FreeBSD: src/bin/ps/Makefile,v 1.27 2005/01/27 13:42:40 delphij Exp $
+# $FreeBSD: stable/10/bin/ps/Makefile 266279 2014-05-17 02:32:47Z bdrewery $
# @(#)Makefile 8.1 (Berkeley) 6/2/93
PROG= ps
@@ -12,7 +12,7 @@
# on large systems.
#
CFLAGS+=-DLAZY_PS
-DPADD= ${LIBM} ${LIBKVM}
-LDADD= -lm -lkvm
+DPADD= ${LIBM} ${LIBKVM} ${LIBJAIL}
+LDADD= -lm -lkvm -ljail
.include <bsd.prog.mk>
Modified: trunk/bin/ps/extern.h
===================================================================
--- trunk/bin/ps/extern.h 2018-06-30 23:44:18 UTC (rev 11187)
+++ trunk/bin/ps/extern.h 2018-06-30 23:45:13 UTC (rev 11188)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -27,8 +28,7 @@
* SUCH DAMAGE.
*
* @(#)extern.h 8.3 (Berkeley) 4/2/94
- * $FreeBSD: src/bin/ps/extern.h,v 1.37 2004/06/23 23:48:09 gad Exp $
- * $MidnightBSD$
+ * $FreeBSD: stable/10/bin/ps/extern.h 331471 2018-03-24 00:26:42Z jhb $
*/
struct kinfo;
@@ -54,6 +54,7 @@
VARENT *find_varentry(VAR *);
const char *fmt_argv(char **, char *, char *, size_t);
double getpcpu(const KINFO *);
+char *jailname(KINFO *, VARENT *);
char *kvar(KINFO *, VARENT *);
char *label(KINFO *, VARENT *);
char *loginclass(KINFO *, VARENT *);
Modified: trunk/bin/ps/fmt.c
===================================================================
--- trunk/bin/ps/fmt.c 2018-06-30 23:44:18 UTC (rev 11187)
+++ trunk/bin/ps/fmt.c 2018-06-30 23:45:13 UTC (rev 11188)
@@ -35,7 +35,7 @@
#endif
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/bin/ps/fmt.c,v 1.34 2004/06/22 02:18:29 gad Exp $");
+__FBSDID("$FreeBSD: stable/10/bin/ps/fmt.c 245635 2013-01-19 00:21:55Z jhb $");
#include <sys/types.h>
#include <sys/time.h>
Modified: trunk/bin/ps/keyword.c
===================================================================
--- trunk/bin/ps/keyword.c 2018-06-30 23:44:18 UTC (rev 11187)
+++ trunk/bin/ps/keyword.c 2018-06-30 23:45:13 UTC (rev 11188)
@@ -34,7 +34,7 @@
#endif /* not lint */
#endif
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: /repoman/r/ncvs/src/bin/ps/keyword.c,v 1.72.2.3 2006/04/14 02:47:30 gad Exp $");
+__FBSDID("$FreeBSD: stable/10/bin/ps/keyword.c 331471 2018-03-24 00:26:42Z jhb $");
#include <sys/param.h>
#include <sys/time.h>
@@ -88,12 +88,16 @@
{"etimes", "ELAPSED", NULL, USER, elapseds, 0, CHAR, NULL, 0},
{"euid", "", "uid", 0, NULL, 0, CHAR, NULL, 0},
{"f", "F", NULL, 0, kvar, KOFF(ki_flag), INT, "x", 0},
+ {"f2", "F2", NULL, 0, kvar, KOFF(ki_flag2), INT, "08x", 0},
+ {"fib", "FIB", NULL, 0, kvar, KOFF(ki_fibnum), INT, "d", 0},
{"flags", "", "f", 0, NULL, 0, CHAR, NULL, 0},
+ {"flags2", "", "f2", 0, NULL, 0, CHAR, NULL, 0},
{"gid", "GID", NULL, 0, kvar, KOFF(ki_groups), UINT, UIDFMT, 0},
{"group", "GROUP", NULL, LJUST, egroupname, 0, CHAR, NULL, 0},
{"ignored", "", "sigignore", 0, NULL, 0, CHAR, NULL, 0},
{"inblk", "INBLK", NULL, USER, rvar, ROFF(ru_inblock), LONG, "ld", 0},
{"inblock", "", "inblk", 0, NULL, 0, CHAR, NULL, 0},
+ {"jail", "JAIL", NULL, LJUST, jailname, 0, CHAR, NULL, 0},
{"jid", "JID", NULL, 0, kvar, KOFF(ki_jid), INT, "d", 0},
{"jobc", "JOBC", NULL, 0, kvar, KOFF(ki_jobc), SHORT, "d", 0},
{"ktrace", "KTRACE", NULL, 0, kvar, KOFF(ki_traceflag), INT, "x", 0},
Modified: trunk/bin/ps/nlist.c
===================================================================
--- trunk/bin/ps/nlist.c 2018-06-30 23:44:18 UTC (rev 11187)
+++ trunk/bin/ps/nlist.c 2018-06-30 23:45:13 UTC (rev 11188)
@@ -35,7 +35,7 @@
#endif
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/bin/ps/nlist.c,v 1.21 2004/04/06 20:06:49 markm Exp $");
+__FBSDID("$FreeBSD: stable/10/bin/ps/nlist.c 127958 2004-04-06 20:06:54Z markm $");
#include <sys/types.h>
#include <sys/sysctl.h>
Modified: trunk/bin/ps/print.c
===================================================================
--- trunk/bin/ps/print.c 2018-06-30 23:44:18 UTC (rev 11187)
+++ trunk/bin/ps/print.c 2018-06-30 23:45:13 UTC (rev 11188)
@@ -1,4 +1,4 @@
-/* $MidnightBSD: src/bin/ps/print.c,v 1.2 2007/07/26 20:13:00 laffer1 Exp $ */
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1990, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -35,7 +35,7 @@
#endif
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/bin/ps/print.c,v 1.93 2004/07/20 05:52:00 tjr Exp $");
+__FBSDID("$FreeBSD: stable/10/bin/ps/print.c 331471 2018-03-24 00:26:42Z jhb $");
#include <sys/param.h>
#include <sys/time.h>
@@ -50,6 +50,7 @@
#include <err.h>
#include <grp.h>
+#include <jail.h>
#include <langinfo.h>
#include <locale.h>
#include <math.h>
@@ -100,10 +101,8 @@
char *
arguments(KINFO *k, VARENT *ve)
{
- VAR *v;
char *vis_args;
- v = ve->var;
if ((vis_args = malloc(strlen(k->ki_args) * 4 + 1)) == NULL)
errx(1, "malloc failed");
strvis(vis_args, k->ki_args, VIS_TAB | VIS_NL | VIS_NOSLASH);
@@ -117,18 +116,17 @@
char *
command(KINFO *k, VARENT *ve)
{
- VAR *v;
char *vis_args, *vis_env, *str;
- v = ve->var;
if (cflag) {
/* If it is the last field, then don't pad */
if (STAILQ_NEXT(ve, next_ve) == NULL) {
- asprintf(&str, "%s%s%s%s",
+ asprintf(&str, "%s%s%s%s%s",
k->ki_d.prefix ? k->ki_d.prefix : "",
k->ki_p->ki_comm,
(showthreads && k->ki_p->ki_numthreads > 1) ? "/" : "",
- (showthreads && k->ki_p->ki_numthreads > 1) ? k->ki_p->ki_tdname : "");
+ (showthreads && k->ki_p->ki_numthreads > 1) ? k->ki_p->ki_tdname : "",
+ (showthreads && k->ki_p->ki_numthreads > 1) ? k->ki_p->ki_moretdname : "");
} else
str = strdup(k->ki_p->ki_comm);
@@ -173,19 +171,19 @@
char *
ucomm(KINFO *k, VARENT *ve)
{
- VAR *v;
char *str;
- v = ve->var;
if (STAILQ_NEXT(ve, next_ve) == NULL) { /* last field, don't pad */
- asprintf(&str, "%s%s%s%s",
+ asprintf(&str, "%s%s%s%s%s",
k->ki_d.prefix ? k->ki_d.prefix : "",
k->ki_p->ki_comm,
(showthreads && k->ki_p->ki_numthreads > 1) ? "/" : "",
- (showthreads && k->ki_p->ki_numthreads > 1) ? k->ki_p->ki_tdname : "");
+ (showthreads && k->ki_p->ki_numthreads > 1) ? k->ki_p->ki_tdname : "",
+ (showthreads && k->ki_p->ki_numthreads > 1) ? k->ki_p->ki_moretdname : "");
} else {
if (showthreads && k->ki_p->ki_numthreads > 1)
- asprintf(&str, "%s/%s", k->ki_p->ki_comm, k->ki_p->ki_tdname);
+ asprintf(&str, "%s/%s%s", k->ki_p->ki_comm,
+ k->ki_p->ki_tdname, k->ki_p->ki_moretdname);
else
str = strdup(k->ki_p->ki_comm);
}
@@ -193,14 +191,13 @@
}
char *
-tdnam(KINFO *k, VARENT *ve)
+tdnam(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
char *str;
- v = ve->var;
if (showthreads && k->ki_p->ki_numthreads > 1)
- str = strdup(k->ki_p->ki_tdname);
+ asprintf(&str, "%s%s", k->ki_p->ki_tdname,
+ k->ki_p->ki_moretdname);
else
str = strdup(" ");
@@ -208,11 +205,9 @@
}
char *
-logname(KINFO *k, VARENT *ve)
+logname(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
- v = ve->var;
if (*k->ki_p->ki_login == '\0')
return (NULL);
return (strdup(k->ki_p->ki_login));
@@ -219,17 +214,15 @@
}
char *
-state(KINFO *k, VARENT *ve)
+state(KINFO *k, VARENT *ve __unused)
{
int flag, tdflags;
char *cp, *buf;
- VAR *v;
buf = malloc(16);
if (buf == NULL)
errx(1, "malloc failed");
- v = ve->var;
flag = k->ki_p->ki_flag;
tdflags = k->ki_p->ki_tdflags; /* XXXKSE */
cp = buf;
@@ -295,23 +288,19 @@
#define scalepri(x) ((x) - PZERO)
char *
-pri(KINFO *k, VARENT *ve)
+pri(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
char *str;
- v = ve->var;
asprintf(&str, "%d", scalepri(k->ki_p->ki_pri.pri_level));
return (str);
}
char *
-upr(KINFO *k, VARENT *ve)
+upr(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
char *str;
- v = ve->var;
asprintf(&str, "%d", scalepri(k->ki_p->ki_pri.pri_user));
return (str);
}
@@ -318,69 +307,57 @@
#undef scalepri
char *
-uname(KINFO *k, VARENT *ve)
+uname(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
- v = ve->var;
return (strdup(user_from_uid(k->ki_p->ki_uid, 0)));
}
char *
-egroupname(KINFO *k, VARENT *ve)
+egroupname(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
- v = ve->var;
return (strdup(group_from_gid(k->ki_p->ki_groups[0], 0)));
}
char *
-rgroupname(KINFO *k, VARENT *ve)
+rgroupname(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
- v = ve->var;
return (strdup(group_from_gid(k->ki_p->ki_rgid, 0)));
}
char *
-runame(KINFO *k, VARENT *ve)
+runame(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
- v = ve->var;
return (strdup(user_from_uid(k->ki_p->ki_ruid, 0)));
}
char *
-tdev(KINFO *k, VARENT *ve)
+tdev(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
dev_t dev;
char *str;
- v = ve->var;
dev = k->ki_p->ki_tdev;
if (dev == NODEV)
- str = strdup("??");
+ str = strdup("-");
else
- asprintf(&str, "%d/%d", major(dev), minor(dev));
+ asprintf(&str, "%#jx", (uintmax_t)dev);
return (str);
}
char *
-tname(KINFO *k, VARENT *ve)
+tname(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
dev_t dev;
char *ttname, *str;
- v = ve->var;
dev = k->ki_p->ki_tdev;
if (dev == NODEV || (ttname = devname(dev, S_IFCHR)) == NULL)
- str = strdup("?? ");
+ str = strdup("- ");
else {
if (strncmp(ttname, "tty", 3) == 0 ||
strncmp(ttname, "cua", 3) == 0)
@@ -395,24 +372,21 @@
}
char *
-longtname(KINFO *k, VARENT *ve)
+longtname(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
dev_t dev;
const char *ttname;
- v = ve->var;
dev = k->ki_p->ki_tdev;
if (dev == NODEV || (ttname = devname(dev, S_IFCHR)) == NULL)
- ttname = "??";
+ ttname = "-";
return (strdup(ttname));
}
char *
-started(KINFO *k, VARENT *ve)
+started(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
time_t then;
struct tm *tp;
static int use_ampm = -1;
@@ -419,13 +393,13 @@
size_t buflen = 100;
char *buf;
+ if (!k->ki_valid)
+ return (NULL);
+
buf = malloc(buflen);
if (buf == NULL)
errx(1, "malloc failed");
- v = ve->var;
- if (!k->ki_valid)
- return (NULL);
if (use_ampm < 0)
use_ampm = (*nl_langinfo(T_FMT_AMPM) != '\0');
then = k->ki_p->ki_start.tv_sec;
@@ -442,20 +416,19 @@
}
char *
-lstarted(KINFO *k, VARENT *ve)
+lstarted(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
time_t then;
char *buf;
size_t buflen = 100;
+ if (!k->ki_valid)
+ return (NULL);
+
buf = malloc(buflen);
if (buf == NULL)
errx(1, "malloc failed");
- v = ve->var;
- if (!k->ki_valid)
- return (NULL);
then = k->ki_p->ki_start.tv_sec;
(void)strftime(buf, buflen, "%c", localtime(&then));
return (buf);
@@ -462,12 +435,10 @@
}
char *
-lockname(KINFO *k, VARENT *ve)
+lockname(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
char *str;
- v = ve->var;
if (k->ki_p->ki_kiflag & KI_LOCKBLOCK) {
if (k->ki_p->ki_lockname[0] != 0)
str = strdup(k->ki_p->ki_lockname);
@@ -480,12 +451,10 @@
}
char *
-wchan(KINFO *k, VARENT *ve)
+wchan(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
char *str;
- v = ve->var;
if (k->ki_p->ki_wchan) {
if (k->ki_p->ki_wmesg[0] != 0)
str = strdup(k->ki_p->ki_wmesg);
@@ -498,12 +467,10 @@
}
char *
-nwchan(KINFO *k, VARENT *ve)
+nwchan(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
char *str;
- v = ve->var;
if (k->ki_p->ki_wchan)
asprintf(&str, "%0lx", (long)k->ki_p->ki_wchan);
else
@@ -513,12 +480,10 @@
}
char *
-mwchan(KINFO *k, VARENT *ve)
+mwchan(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
char *str;
- v = ve->var;
if (k->ki_p->ki_wchan) {
if (k->ki_p->ki_wmesg[0] != 0)
str = strdup(k->ki_p->ki_wmesg);
@@ -536,27 +501,23 @@
}
char *
-vsize(KINFO *k, VARENT *ve)
+vsize(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
char *str;
- v = ve->var;
asprintf(&str, "%lu", (u_long)(k->ki_p->ki_size / 1024));
return (str);
}
static char *
-printtime(KINFO *k, VARENT *ve, long secs, long psecs)
+printtime(KINFO *k, VARENT *ve __unused, long secs, long psecs)
/* psecs is "parts" of a second. first micro, then centi */
{
- VAR *v;
static char decimal_point;
char *str;
if (decimal_point == '\0')
decimal_point = localeconv()->decimal_point[0];
- v = ve->var;
if (!k->ki_valid) {
secs = 0;
psecs = 0;
@@ -619,14 +580,12 @@
}
char *
-elapsed(KINFO *k, VARENT *ve)
+elapsed(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
time_t val;
int days, hours, mins, secs;
char *str;
- v = ve->var;
if (!k->ki_valid)
return (NULL);
val = now - k->ki_p->ki_start.tv_sec;
@@ -647,13 +606,11 @@
}
char *
-elapseds(KINFO *k, VARENT *ve)
+elapseds(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
time_t val;
char *str;
- v = ve->var;
if (!k->ki_valid)
return (NULL);
val = now - k->ki_p->ki_start.tv_sec;
@@ -683,12 +640,10 @@
}
char *
-pcpu(KINFO *k, VARENT *ve)
+pcpu(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
char *str;
- v = ve->var;
asprintf(&str, "%.1f", getpcpu(k));
return (str);
}
@@ -713,23 +668,19 @@
}
char *
-pmem(KINFO *k, VARENT *ve)
+pmem(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
char *str;
- v = ve->var;
asprintf(&str, "%.1f", getpmem(k));
return (str);
}
char *
-pagein(KINFO *k, VARENT *ve)
+pagein(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
char *str;
- v = ve->var;
asprintf(&str, "%ld", k->ki_valid ? k->ki_p->ki_rusage.ru_majflt : 0);
return (str);
}
@@ -736,24 +687,20 @@
/* ARGSUSED */
char *
-maxrss(KINFO *k __unused, VARENT *ve)
+maxrss(KINFO *k __unused, VARENT *ve __unused)
{
- VAR *v;
- v = ve->var;
/* XXX not yet */
return (NULL);
}
char *
-priorityr(KINFO *k, VARENT *ve)
+priorityr(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
struct priority *lpri;
char *str;
unsigned class, level;
- v = ve->var;
lpri = &k->ki_p->ki_pri;
class = lpri->pri_class;
level = lpri->pri_level;
@@ -853,25 +800,19 @@
}
char *
-emulname(KINFO *k, VARENT *ve)
+emulname(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
- v = ve->var;
- if (k->ki_p->ki_emul == NULL)
- return (NULL);
return (strdup(k->ki_p->ki_emul));
}
char *
-label(KINFO *k, VARENT *ve)
+label(KINFO *k, VARENT *ve __unused)
{
char *string;
- VAR *v;
mac_t proclabel;
int error;
- v = ve->var;
string = NULL;
if (mac_prepare_process_label(&proclabel) == -1) {
warn("mac_prepare_process_label");
@@ -888,12 +829,9 @@
}
char *
-loginclass(KINFO *k, VARENT *ve)
+loginclass(KINFO *k, VARENT *ve __unused)
{
- VAR *v;
- char *s;
- v = ve->var;
/*
* Don't display login class for system processes;
* login classes are used for resource limits,
@@ -902,8 +840,18 @@
if (k->ki_p->ki_flag & P_SYSTEM) {
return (strdup("-"));
}
- s = k->ki_p->ki_loginclass;
- if (s == NULL)
- return (NULL);
- return (strdup(s));
+ return (strdup(k->ki_p->ki_loginclass));
}
+
+char *
+jailname(KINFO *k, VARENT *ve __unused)
+{
+ char *name;
+
+ if (k->ki_p->ki_jid == 0)
+ return (strdup("-"));
+ name = jail_getname(k->ki_p->ki_jid);
+ if (name == NULL)
+ return (strdup("-"));
+ return (name);
+}
Modified: trunk/bin/ps/ps.1
===================================================================
--- trunk/bin/ps/ps.1 2018-06-30 23:44:18 UTC (rev 11187)
+++ trunk/bin/ps/ps.1 2018-06-30 23:45:13 UTC (rev 11188)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\"-
.\" Copyright (c) 1980, 1990, 1991, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
@@ -27,10 +28,9 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)ps.1 8.3 (Berkeley) 4/18/94
-.\" $FreeBSD: /repoman/r/ncvs/src/bin/ps/ps.1,v 1.86.2.1 2006/08/22 08:25:17 yar Exp $
-.\" $MidnightBSD: src/bin/ps/ps.1,v 1.3 2007/07/26 20:13:00 laffer1 Exp $
+.\" $FreeBSD: stable/10/bin/ps/ps.1 331471 2018-03-24 00:26:42Z jhb $
.\"
-.Dd February 7, 2013
+.Dd March 13, 2018
.Dt PS 1
.Os
.Sh NAME
@@ -41,6 +41,7 @@
.Op Fl aCcdefHhjlmrSTuvwXxZ
.Op Fl O Ar fmt | Fl o Ar fmt
.Op Fl G Ar gid Ns Op , Ns Ar gid Ns Ar ...
+.Op Fl J Ar jid Ns Op , Ns Ar jid Ns Ar ...
.Op Fl M Ar core
.Op Fl N Ar system
.Op Fl p Ar pid Ns Op , Ns Ar pid Ns Ar ...
@@ -63,7 +64,7 @@
.Pp
A different set of processes can be selected for display by using any
combination of the
-.Fl a , G , p , T , t ,
+.Fl a , G , J , p , T , t ,
and
.Fl U
options.
@@ -153,6 +154,20 @@
.Cm user , pid , ppid , pgid , sid , jobc , state , tt , time ,
and
.Cm command .
+.It Fl J
+Display information about processes which match the specified jail IDs.
+This may be either the
+.Cm jid
+or
+.Cm name
+of the jail.
+Use
+.Fl J
+.Sy 0
+to display only host processes.
+This flag implies
+.Fl x
+by default.
.It Fl L
List the set of keywords available for the
.Fl O
@@ -293,39 +308,48 @@
the include file
.In sys/proc.h :
.Bl -column P_SINGLE_BOUNDARY 0x40000000
-.It Dv "P_ADVLOCK" Ta No "0x00001 Process may hold a POSIX advisory lock"
-.It Dv "P_CONTROLT" Ta No "0x00002 Has a controlling terminal"
-.It Dv "P_KTHREAD" Ta No "0x00004 Kernel thread"
-.It Dv "P_FOLLOWFORK" Ta No "0x00008 Attach debugger to new children"
-.It Dv "P_PPWAIT" Ta No "0x00010 Parent is waiting for child to exec/exit"
-.It Dv "P_PROFIL" Ta No "0x00020 Has started profiling"
-.It Dv "P_STOPPROF" Ta No "0x00040 Has thread in requesting to stop prof"
-.It Dv "P_HADTHREADS" Ta No "0x00080 Has had threads (no cleanup shortcuts)"
-.It Dv "P_SUGID" Ta No "0x00100 Had set id privileges since last exec"
-.It Dv "P_SYSTEM" Ta No "0x00200 System proc: no sigs, stats or swapping"
-.It Dv "P_SINGLE_EXIT" Ta No "0x00400 Threads suspending should exit, not wait"
-.It Dv "P_TRACED" Ta No "0x00800 Debugged process being traced"
-.It Dv "P_WAITED" Ta No "0x01000 Someone is waiting for us"
-.It Dv "P_WEXIT" Ta No "0x02000 Working on exiting"
-.It Dv "P_EXEC" Ta No "0x04000 Process called exec"
-.It Dv "P_WKILLED" Ta No "0x08000 Killed, shall go to kernel/user boundary ASAP"
-.It Dv "P_CONTINUED" Ta No "0x10000 Proc has continued from a stopped state"
-.It Dv "P_STOPPED_SIG" Ta No "0x20000 Stopped due to SIGSTOP/SIGTSTP"
-.It Dv "P_STOPPED_TRACE" Ta No "0x40000 Stopped because of tracing"
-.It Dv "P_STOPPED_SINGLE" Ta No "0x80000 Only one thread can continue"
-.It Dv "P_PROTECTED" Ta No "0x100000 Do not kill on memory overcommit"
-.It Dv "P_SIGEVENT" Ta No "0x200000 Process pending signals changed"
-.It Dv "P_SINGLE_BOUNDARY" Ta No "0x400000 Threads should suspend at user boundary"
-.It Dv "P_HWPMC" Ta No "0x800000 Process is using HWPMCs"
-.It Dv "P_JAILED" Ta No "0x1000000 Process is in jail"
-.It Dv "P_ORPHAN" Ta No "0x2000000 Orphaned by original parent, reparented to debugger"
-.It Dv "P_INEXEC" Ta No "0x4000000 Process is in execve()"
-.It Dv "P_STATCHILD" Ta No "0x8000000 Child process stopped or exited"
-.It Dv "P_INMEM" Ta No "0x10000000 Loaded into memory"
-.It Dv "P_SWAPPINGOUT" Ta No "0x20000000 Process is being swapped out"
-.It Dv "P_SWAPPINGIN" Ta No "0x40000000 Process is being swapped in"
+.It Dv "P_ADVLOCK" Ta No "0x00001" Ta "Process may hold a POSIX advisory lock"
+.It Dv "P_CONTROLT" Ta No "0x00002" Ta "Has a controlling terminal"
+.It Dv "P_KTHREAD" Ta No "0x00004" Ta "Kernel thread"
+.It Dv "P_PPWAIT" Ta No "0x00010" Ta "Parent is waiting for child to exec/exit"
+.It Dv "P_PROFIL" Ta No "0x00020" Ta "Has started profiling"
+.It Dv "P_STOPPROF" Ta No "0x00040" Ta "Has thread in requesting to stop prof"
+.It Dv "P_HADTHREADS" Ta No "0x00080" Ta "Has had threads (no cleanup shortcuts)"
+.It Dv "P_SUGID" Ta No "0x00100" Ta "Had set id privileges since last exec"
+.It Dv "P_SYSTEM" Ta No "0x00200" Ta "System proc: no sigs, stats or swapping"
+.It Dv "P_SINGLE_EXIT" Ta No "0x00400" Ta "Threads suspending should exit, not wait"
+.It Dv "P_TRACED" Ta No "0x00800" Ta "Debugged process being traced"
+.It Dv "P_WAITED" Ta No "0x01000" Ta "Someone is waiting for us"
+.It Dv "P_WEXIT" Ta No "0x02000" Ta "Working on exiting"
+.It Dv "P_EXEC" Ta No "0x04000" Ta "Process called exec"
+.It Dv "P_WKILLED" Ta No "0x08000" Ta "Killed, shall go to kernel/user boundary ASAP"
+.It Dv "P_CONTINUED" Ta No "0x10000" Ta "Proc has continued from a stopped state"
+.It Dv "P_STOPPED_SIG" Ta No "0x20000" Ta "Stopped due to SIGSTOP/SIGTSTP"
+.It Dv "P_STOPPED_TRACE" Ta No "0x40000" Ta "Stopped because of tracing"
+.It Dv "P_STOPPED_SINGLE" Ta No "0x80000" Ta "Only one thread can continue"
+.It Dv "P_PROTECTED" Ta No "0x100000" Ta "Do not kill on memory overcommit"
+.It Dv "P_SIGEVENT" Ta No "0x200000" Ta "Process pending signals changed"
+.It Dv "P_SINGLE_BOUNDARY" Ta No "0x400000" Ta "Threads should suspend at user boundary"
+.It Dv "P_HWPMC" Ta No "0x800000" Ta "Process is using HWPMCs"
+.It Dv "P_JAILED" Ta No "0x1000000" Ta "Process is in jail"
+.It Dv "P_TOTAL_STOP" Ta No "0x2000000" Ta "Stopped for system suspend"
+.It Dv "P_INEXEC" Ta No "0x4000000" Ta "Process is in execve()"
+.It Dv "P_STATCHILD" Ta No "0x8000000" Ta "Child process stopped or exited"
+.It Dv "P_INMEM" Ta No "0x10000000" Ta "Loaded into memory"
+.It Dv "P_SWAPPINGOUT" Ta No "0x20000000" Ta "Process is being swapped out"
+.It Dv "P_SWAPPINGIN" Ta No "0x40000000" Ta "Process is being swapped in"
.It Dv "P_PPTRACE" Ta No "0x80000000" Ta "Vforked child issued ptrace(PT_TRACEME)"
.El
+.It Cm flags2
+The flags kept in
+.Va p_flag2
+associated with the process as in
+the include file
+.In sys/proc.h :
+.Bl -column P2_INHERIT_PROTECTED 0x00000001
+.It Dv "P2_INHERIT_PROTECTED" Ta No "0x00000001" Ta "New children get P_PROTECTED"
+.It Dv "P2_PTRACE_FSTP" Ta No "0x00000010" Ta "SIGSTOP from PT_ATTACH not yet handled"
+.El
.It Cm label
The MAC label of the process.
.It Cm lim
@@ -434,6 +458,10 @@
.Ql -
if the process can no longer reach that
controlling terminal (i.e., it has been revoked).
+A
+.Ql -
+without a preceding two letter abbreviation or pseudo-terminal device number
+indicates a process which never had a controlling terminal.
The full pathname of the controlling terminal is available via the
.Cm tty
keyword.
@@ -509,9 +537,15 @@
minutes:seconds.
.It Cm etimes
elapsed running time, in decimal integer seconds
+.It Cm fib
+default FIB number, see
+.Xr setfib 1
.It Cm flags
the process flags, in hexadecimal (alias
.Cm f )
+.It Cm flags2
+the additional set of process flags, in hexadecimal (alias
+.Cm f2 )
.It Cm gid
effective group ID (alias
.Cm egid )
@@ -521,6 +555,8 @@
.It Cm inblk
total blocks read (alias
.Cm inblock )
+.It Cm jail
+jail name
.It Cm jid
jail ID
.It Cm jobc
@@ -686,6 +722,10 @@
.It Pa /boot/kernel/kernel
default system namelist
.El
+.Sh EXAMPLES
+Display information on all system processes:
+.Pp
+.Dl $ ps -auxw
.Sh SEE ALSO
.Xr kill 1 ,
.Xr pgrep 1 ,
Property changes on: trunk/bin/ps/ps.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/bin/ps/ps.c
===================================================================
--- trunk/bin/ps/ps.c 2018-06-30 23:44:18 UTC (rev 11187)
+++ trunk/bin/ps/ps.c 2018-06-30 23:45:13 UTC (rev 11188)
@@ -48,9 +48,10 @@
#endif
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/bin/ps/ps.c,v 1.110 2005/02/09 17:37:38 ru Exp $");
+__FBSDID("$FreeBSD: stable/10/bin/ps/ps.c 301148 2016-06-01 17:33:02Z truckman $");
#include <sys/param.h>
+#include <sys/jail.h>
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/stat.h>
@@ -63,6 +64,7 @@
#include <errno.h>
#include <fcntl.h>
#include <grp.h>
+#include <jail.h>
#include <kvm.h>
#include <limits.h>
#include <locale.h>
@@ -110,6 +112,7 @@
static int needenv; /* -e */
static int needuser; /* -o "user" */
static int optfatal; /* Fatal error parsing some list-option. */
+static int pid_max; /* kern.max_pid */
static enum sort { DEFAULT, SORTMEM, SORTCPU } sortby = DEFAULT;
@@ -124,6 +127,7 @@
const char *lname;
union {
gid_t *gids;
+ int *jids;
pid_t *pids;
dev_t *ttys;
uid_t *uids;
@@ -132,6 +136,7 @@
};
static int addelem_gid(struct listinfo *, const char *);
+static int addelem_jid(struct listinfo *, const char *);
static int addelem_pid(struct listinfo *, const char *);
static int addelem_tty(struct listinfo *, const char *);
static int addelem_uid(struct listinfo *, const char *);
@@ -149,6 +154,7 @@
static void saveuser(KINFO *);
static void scanvars(void);
static void sizevars(void);
+static void pidmax_init(void);
static void usage(void);
static char dfmt[] = "pid,tt,state,time,command";
@@ -162,12 +168,12 @@
"%cpu,%mem,command";
static char Zfmt[] = "label";
-#define PS_ARGS "AaCcde" OPT_LAZY_f "G:gHhjLlM:mN:O:o:p:rSTt:U:uvwXxZ"
+#define PS_ARGS "AaCcde" OPT_LAZY_f "G:gHhjJ:LlM:mN:O:o:p:rSTt:U:uvwXxZ"
int
main(int argc, char *argv[])
{
- struct listinfo gidlist, pgrplist, pidlist;
+ struct listinfo gidlist, jidlist, pgrplist, pidlist;
struct listinfo ruidlist, sesslist, ttylist, uidlist;
struct kinfo_proc *kp;
KINFO *kinfo = NULL, *next_KINFO;
@@ -201,10 +207,13 @@
if (argc > 1)
argv[1] = kludge_oldps_options(PS_ARGS, argv[1], argv[2]);
+ pidmax_init();
+
all = descendancy = _fmt = nselectors = optfatal = 0;
prtheader = showthreads = wflag = xkeep_implied = 0;
xkeep = -1; /* Neither -x nor -X. */
init_list(&gidlist, addelem_gid, sizeof(gid_t), "group");
+ init_list(&jidlist, addelem_jid, sizeof(int), "jail id");
init_list(&pgrplist, addelem_pid, sizeof(pid_t), "process group");
init_list(&pidlist, addelem_pid, sizeof(pid_t), "process id");
init_list(&ruidlist, addelem_uid, sizeof(uid_t), "ruser");
@@ -272,6 +281,11 @@
case 'h':
prtheader = ws.ws_row > 5 ? ws.ws_row : 22;
break;
+ case 'J':
+ add_list(&jidlist, optarg);
+ xkeep_implied = 1;
+ nselectors++;
+ break;
case 'j':
parsefmt(jfmt, 0);
_fmt = 1;
@@ -535,6 +549,11 @@
if (kp->ki_rgid == gidlist.l.gids[elem])
goto keepit;
}
+ if (jidlist.count > 0) {
+ for (elem = 0; elem < jidlist.count; elem++)
+ if (kp->ki_jid == jidlist.l.jids[elem])
+ goto keepit;
+ }
if (pgrplist.count > 0) {
for (elem = 0; elem < pgrplist.count; elem++)
if (kp->ki_pgid ==
@@ -626,7 +645,7 @@
ks = STAILQ_FIRST(&kinfo[i].ki_ks);
STAILQ_REMOVE_HEAD(&kinfo[i].ki_ks, ks_next);
- /* Truncate rightmost column if neccessary. */
+ /* Truncate rightmost column if necessary. */
if (STAILQ_NEXT(vent, next_ve) == NULL &&
termwidth != UNLIMITED && ks->ks_str != NULL) {
left = termwidth - linelen;
@@ -663,6 +682,7 @@
}
}
free_list(&gidlist);
+ free_list(&jidlist);
free_list(&pidlist);
free_list(&pgrplist);
free_list(&ruidlist);
@@ -723,8 +743,31 @@
return (1);
}
-#define BSD_PID_MAX 99999 /* Copy of PID_MAX from sys/proc.h. */
static int
+addelem_jid(struct listinfo *inf, const char *elem)
+{
+ int tempid;
+
+ if (*elem == '\0') {
+ warnx("Invalid (zero-length) jail id");
+ optfatal = 1;
+ return (0); /* Do not add this value. */
+ }
+
+ tempid = jail_getid(elem);
+ if (tempid < 0) {
+ warnx("Invalid %s: %s", inf->lname, elem);
+ optfatal = 1;
+ return (0);
+ }
+
+ if (inf->count >= inf->maxcount)
+ expand_list(inf);
+ inf->l.jids[(inf->count)++] = tempid;
+ return (1);
+}
+
+static int
addelem_pid(struct listinfo *inf, const char *elem)
{
char *endp;
@@ -741,7 +784,7 @@
if (*endp != '\0' || tempid < 0 || elem == endp) {
warnx("Invalid %s: %s", inf->lname, elem);
errno = ERANGE;
- } else if (errno != 0 || tempid > BSD_PID_MAX) {
+ } else if (errno != 0 || tempid > pid_max) {
warnx("%s too large: %s", inf->lname, elem);
errno = ERANGE;
}
@@ -754,7 +797,6 @@
inf->l.pids[(inf->count)++] = tempid;
return (1);
}
-#undef BSD_PID_MAX
/*-
* The user can specify a device via one of three formats:
@@ -1176,6 +1218,7 @@
static void
saveuser(KINFO *ki)
{
+ char *argsp;
if (ki->ki_p->ki_flag & P_INMEM) {
/*
@@ -1194,10 +1237,12 @@
if (ki->ki_p->ki_stat == SZOMB)
ki->ki_args = strdup("<defunct>");
else if (UREADOK(ki) || (ki->ki_p->ki_args != NULL))
- ki->ki_args = strdup(fmt(kvm_getargv, ki,
- ki->ki_p->ki_comm, ki->ki_p->ki_tdname, MAXCOMLEN));
- else
- asprintf(&ki->ki_args, "(%s)", ki->ki_p->ki_comm);
+ ki->ki_args = fmt(kvm_getargv, ki,
+ ki->ki_p->ki_comm, ki->ki_p->ki_tdname, MAXCOMLEN);
+ else {
+ asprintf(&argsp, "(%s)", ki->ki_p->ki_comm);
+ ki->ki_args = argsp;
+ }
if (ki->ki_args == NULL)
errx(1, "malloc failed");
} else {
@@ -1205,8 +1250,8 @@
}
if (needenv) {
if (UREADOK(ki))
- ki->ki_env = strdup(fmt(kvm_getenvv, ki,
- (char *)NULL, (char *)NULL, 0));
+ ki->ki_env = fmt(kvm_getenvv, ki,
+ (char *)NULL, (char *)NULL, 0);
else
ki->ki_env = strdup("()");
if (ki->ki_env == NULL)
@@ -1354,6 +1399,18 @@
}
static void
+pidmax_init(void)
+{
+ size_t intsize;
+
+ intsize = sizeof(pid_max);
+ if (sysctlbyname("kern.pid_max", &pid_max, &intsize, NULL, 0) < 0) {
+ warn("unable to read kern.pid_max");
+ pid_max = 99999;
+ }
+}
+
+static void
usage(void)
{
#define SINGLE_OPTS "[-aCcde" OPT_LAZY_f "HhjlmrSTuvwXxZ]"
@@ -1360,7 +1417,7 @@
(void)fprintf(stderr, "%s\n%s\n%s\n%s\n",
"usage: ps " SINGLE_OPTS " [-O fmt | -o fmt] [-G gid[,gid...]]",
- " [-M core] [-N system]",
+ " [-J jid[,jid...]] [-M core] [-N system]",
" [-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]",
" ps [-L]");
exit(1);
Modified: trunk/bin/ps/ps.h
===================================================================
--- trunk/bin/ps/ps.h 2018-06-30 23:44:18 UTC (rev 11187)
+++ trunk/bin/ps/ps.h 2018-06-30 23:45:13 UTC (rev 11188)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -27,8 +28,7 @@
* SUCH DAMAGE.
*
* @(#)ps.h 8.1 (Berkeley) 5/31/93
- * $FreeBSD: src/bin/ps/ps.h,v 1.19 2004/06/23 23:48:09 gad Exp $
- * $MidnightBSD: src/bin/ps/ps.h,v 1.2 2007/07/26 20:13:00 laffer1 Exp $
+ * $FreeBSD: stable/10/bin/ps/ps.h 301148 2016-06-01 17:33:02Z truckman $
*/
#include <sys/queue.h>
@@ -43,8 +43,8 @@
typedef struct kinfo {
struct kinfo_proc *ki_p; /* kinfo_proc structure */
- char *ki_args; /* exec args */
- char *ki_env; /* environment */
+ const char *ki_args; /* exec args */
+ const char *ki_env; /* environment */
int ki_valid; /* 1 => uarea stuff valid */
double ki_pcpu; /* calculated in main() */
segsz_t ki_memsize; /* calculated in main() */
More information about the Midnightbsd-cvs
mailing list