summaryrefslogtreecommitdiff
path: root/usr/src/lib/libproc/common
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libproc/common')
-rw-r--r--usr/src/lib/libproc/common/libproc.h5
-rw-r--r--usr/src/lib/libproc/common/proc_arg.c22
2 files changed, 15 insertions, 12 deletions
diff --git a/usr/src/lib/libproc/common/libproc.h b/usr/src/lib/libproc/common/libproc.h
index 3d2c2978d4..c9807a4da7 100644
--- a/usr/src/lib/libproc/common/libproc.h
+++ b/usr/src/lib/libproc/common/libproc.h
@@ -18,8 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Portions Copyright 2007 Chad Mynhier
@@ -404,7 +405,7 @@ typedef int proc_lwp_all_f(void *, const lwpstatus_t *, const lwpsinfo_t *);
extern int Plwp_iter_all(struct ps_prochandle *, proc_lwp_all_f *, void *);
/*
- * Process iteration interface; iterate over all active processes.
+ * Process iteration interface; iterate over all non-system processes.
*/
typedef int proc_walk_f(psinfo_t *, lwpsinfo_t *, void *);
extern int proc_walk(proc_walk_f *, void *, int);
diff --git a/usr/src/lib/libproc/common/proc_arg.c b/usr/src/lib/libproc/common/proc_arg.c
index c25a89b944..d866127a57 100644
--- a/usr/src/lib/libproc/common/proc_arg.c
+++ b/usr/src/lib/libproc/common/proc_arg.c
@@ -18,15 +18,15 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/proc.h>
#include <libgen.h>
#include <limits.h>
@@ -97,12 +97,12 @@ open_core(const char *arg, int *perr)
(void) close(fd);
fd = -1;
} else if ((is_noelf = memcmp(&ehdr.e_ident[EI_MAG0], ELFMAG,
- SELFMAG)) != 0 || ehdr.e_type != ET_CORE) {
- (void) close(fd);
- fd = -1;
- if (is_noelf == 0 &&
- ehdr.e_ident[EI_DATA] != order)
- *perr = G_ISAINVAL;
+ SELFMAG)) != 0 || ehdr.e_type != ET_CORE) {
+ (void) close(fd);
+ fd = -1;
+ if (is_noelf == 0 &&
+ ehdr.e_ident[EI_DATA] != order)
+ *perr = G_ISAINVAL;
}
} else if (errno == EACCES || errno == EPERM)
*perr = G_PERM;
@@ -422,6 +422,7 @@ proc_lwp_range_valid(const char *set)
/*
* Walk all processes or LWPs in /proc and call func() for each.
+ * Omit system processes (like process-IDs 0, 2, and 3).
* Stop calling func() if it returns non 0 value and return it.
*/
int
@@ -459,7 +460,8 @@ proc_walk(proc_walk_f *func, void *arg, int flag)
fd = open(pidstr, O_RDONLY);
if (fd < 0)
continue;
- if (read(fd, &psinfo, sizeof (psinfo)) != sizeof (psinfo)) {
+ if (read(fd, &psinfo, sizeof (psinfo)) != sizeof (psinfo) ||
+ (psinfo.pr_flag & SSYS)) {
(void) close(fd);
continue;
}