summaryrefslogtreecommitdiffstats
path: root/usr.bin/procstat/procstat_args.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/procstat/procstat_args.c')
-rw-r--r--usr.bin/procstat/procstat_args.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/usr.bin/procstat/procstat_args.c b/usr.bin/procstat/procstat_args.c
index e8e6b94..b13aa72 100644
--- a/usr.bin/procstat/procstat_args.c
+++ b/usr.bin/procstat/procstat_args.c
@@ -42,24 +42,26 @@
static char args[ARG_MAX];
-void
-procstat_args(struct kinfo_proc *kipp)
+static void
+do_args(struct kinfo_proc *kipp, int env)
{
int error, name[4];
size_t len;
char *cp;
if (!hflag)
- printf("%5s %-16s %-53s\n", "PID", "COMM", "ARGS");
+ printf("%5s %-16s %-53s\n", "PID", "COMM",
+ env ? "ENVIRONMENT" : "ARGS");
name[0] = CTL_KERN;
name[1] = KERN_PROC;
- name[2] = KERN_PROC_ARGS;
+ name[2] = env ? KERN_PROC_ENV : KERN_PROC_ARGS;
name[3] = kipp->ki_pid;
len = sizeof(args);
error = sysctl(name, 4, args, &len, NULL, 0);
- if (error < 0 && errno != ESRCH) {
- warn("sysctl: kern.proc.args: %d", kipp->ki_pid);
+ if (error < 0 && errno != ESRCH && errno != EPERM) {
+ warn("sysctl: kern.proc.%s: %d: %d", env ? "env" : "args",
+ kipp->ki_pid, errno);
return;
}
if (error < 0)
@@ -75,3 +77,15 @@ procstat_args(struct kinfo_proc *kipp)
printf("%s%s", cp != args ? " " : "", cp);
printf("\n");
}
+
+void
+procstat_args(struct kinfo_proc *kipp)
+{
+ do_args(kipp, 0);
+}
+
+void
+procstat_env(struct kinfo_proc *kipp)
+{
+ do_args(kipp, 1);
+}
OpenPOWER on IntegriCloud