summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorJason King <jason.king@joyent.com>2019-11-27 09:10:37 -0600
committerJason King <jason.king@joyent.com>2019-12-11 19:05:00 -0600
commita63fed2a0384be5aa3f2ff7a38aac1153c549e87 (patch)
tree5a4e25918d5b764a8b0367d90a38e75d2c0351e3 /usr/src
parent168e1ed4b6c6d87d390ab3eb29cc9e9cb948ef56 (diff)
downloadillumos-joyent-a63fed2a0384be5aa3f2ff7a38aac1153c549e87.tar.gz
12037 ptree zone handling is broken
Reviewed by: John Levon <john.levon@joyent.com> Reviewed by: Andy Fiddaman <andy@omniosce.org> Reviewed by: Robert Mustacchi <rm@fingolfin.org> Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/ptools/ptree/ptree.c2
-rw-r--r--usr/src/lib/libproc/common/libproc.h7
-rw-r--r--usr/src/lib/libproc/common/proc_arg.c18
-rw-r--r--usr/src/man/man3proc/proc_walk.3proc22
4 files changed, 36 insertions, 13 deletions
diff --git a/usr/src/cmd/ptools/ptree/ptree.c b/usr/src/cmd/ptools/ptree/ptree.c
index 82a32bf46c..ad8f47d191 100644
--- a/usr/src/cmd/ptools/ptree/ptree.c
+++ b/usr/src/cmd/ptools/ptree/ptree.c
@@ -212,7 +212,7 @@ main(int argc, char **argv)
ps = NULL;
/* Currently, this can only fail if the 3rd argument is invalid */
- VERIFY0(proc_walk(add_proc, NULL, PR_WALK_PROC));
+ VERIFY0(proc_walk(add_proc, NULL, PR_WALK_PROC|PR_WALK_INCLUDE_SYS));
if (proc0 == NULL)
proc0 = fakepid0();
diff --git a/usr/src/lib/libproc/common/libproc.h b/usr/src/lib/libproc/common/libproc.h
index dd7bd9f99b..f783026060 100644
--- a/usr/src/lib/libproc/common/libproc.h
+++ b/usr/src/lib/libproc/common/libproc.h
@@ -25,7 +25,7 @@
*
* Portions Copyright 2007 Chad Mynhier
* Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
- * Copyright 2018, Joyent, Inc.
+ * Copyright 2019 Joyent, Inc.
* Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright 2019, Carlos Neira <cneirabustos@gmail.com>
* Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
@@ -464,8 +464,9 @@ extern int Plwp_iter_all(struct ps_prochandle *, proc_lwp_all_f *, void *);
typedef int proc_walk_f(psinfo_t *, lwpsinfo_t *, void *);
extern int proc_walk(proc_walk_f *, void *, int);
-#define PR_WALK_PROC 0 /* walk processes only */
-#define PR_WALK_LWP 1 /* walk all lwps */
+#define PR_WALK_PROC 0 /* walk processes only */
+#define PR_WALK_LWP 1 /* walk all lwps */
+#define PR_WALK_INCLUDE_SYS 0x80000000 /* include SSYS processes */
/*
* Determine if an lwp is in a set as returned from proc_arg_xgrab().
diff --git a/usr/src/lib/libproc/common/proc_arg.c b/usr/src/lib/libproc/common/proc_arg.c
index c546e54cc6..f94032d9ba 100644
--- a/usr/src/lib/libproc/common/proc_arg.c
+++ b/usr/src/lib/libproc/common/proc_arg.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2019 Joyent, Inc.
*/
#include <sys/types.h>
@@ -341,14 +342,14 @@ proc_lwp_get_range(char *range, id_t *low, id_t *high)
* The set can include multiple lwpid ranges separated by commas
* and has the following syntax:
*
- * lwp_range[,lwp_range]*
+ * lwp_range[,lwp_range]*
*
* where lwp_range is specifed as:
*
- * -n lwpid <= n
- * n-m n <= lwpid <= m
- * n- lwpid >= n
- * n lwpid == n
+ * -n lwpid <= n
+ * n-m n <= lwpid <= m
+ * n- lwpid >= n
+ * n lwpid == n
*/
int
proc_lwp_in_set(const char *set, lwpid_t lwpid)
@@ -438,6 +439,11 @@ proc_walk(proc_walk_f *func, void *arg, int flag)
id_t pid;
int fd, i;
int ret = 0;
+ boolean_t walk_sys = B_FALSE;
+
+ if ((flag & PR_WALK_INCLUDE_SYS) != 0)
+ walk_sys = B_TRUE;
+ flag &= ~PR_WALK_INCLUDE_SYS;
if (flag != PR_WALK_PROC && flag != PR_WALK_LWP) {
errno = EINVAL;
@@ -458,7 +464,7 @@ proc_walk(proc_walk_f *func, void *arg, int flag)
if (fd < 0)
continue;
if (read(fd, &psinfo, sizeof (psinfo)) != sizeof (psinfo) ||
- (psinfo.pr_flag & SSYS)) {
+ ((psinfo.pr_flag & SSYS) != 0 && !walk_sys)) {
(void) close(fd);
continue;
}
diff --git a/usr/src/man/man3proc/proc_walk.3proc b/usr/src/man/man3proc/proc_walk.3proc
index c1d1158d77..49f0489dc3 100644
--- a/usr/src/man/man3proc/proc_walk.3proc
+++ b/usr/src/man/man3proc/proc_walk.3proc
@@ -9,9 +9,9 @@
.\" http://www.illumos.org/license/CDDL.
.\"
.\"
-.\" Copyright 2015 Joyent, Inc.
+.\" Copyright 2019 Joyent, Inc.
.\"
-.Dd May 11, 2016
+.Dd December 2, 2019
.Dt PROC_WALK 3PROC
.Os
.Sh NAME
@@ -77,6 +77,21 @@ included in the
argument.
.El
.Pp
+In addition, the following values may be combined with one of the above
+values of
+.Fa flag
+with a bitwise-inclusive-OR:
+.Bl -tag -width Dv -offset indent
+.It Dv PR_WALK_INCLUDE_SYS
+Include
+.Sy SYS
+.Pq system
+processes.
+Normally
+.Sy SYS
+processes are skipped during the walk of the process tree.
+.El
+.Pp
The return value of the caller's
.Fa func
function determines whether or not iteration will continue.
@@ -107,7 +122,8 @@ and
functions.
.Bl -tag -width Er
.It Er EINVAL
-.Fa flag is not one of
+.Fa flag
+is not one of
.Dv PR_WALK_PROC
or
.Dv PR_WALK_LWP .