summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/ps/ps.c15
-rw-r--r--bin/ps/ps.h4
2 files changed, 11 insertions, 8 deletions
diff --git a/bin/ps/ps.c b/bin/ps/ps.c
index eeaa9c8..70b6db3 100644
--- a/bin/ps/ps.c
+++ b/bin/ps/ps.c
@@ -1235,6 +1235,7 @@ fmt(char **(*fn)(kvm_t *, const struct kinfo_proc *, int), KINFO *ki,
static void
saveuser(KINFO *ki)
{
+ char *argsp;
if (ki->ki_p->ki_flag & P_INMEM) {
/*
@@ -1253,10 +1254,12 @@ saveuser(KINFO *ki)
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)
xo_errx(1, "malloc failed");
} else {
@@ -1264,8 +1267,8 @@ saveuser(KINFO *ki)
}
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)
diff --git a/bin/ps/ps.h b/bin/ps/ps.h
index 314fbf2..613871a 100644
--- a/bin/ps/ps.h
+++ b/bin/ps/ps.h
@@ -42,8 +42,8 @@ typedef struct kinfo_str {
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() */
OpenPOWER on IntegriCloud