Skip to content

Commit

Permalink
MFC r363649:
Browse files Browse the repository at this point in the history
ps(1): Fix formatting of the "command" field for kernel threads.
  • Loading branch information
markjdb committed Aug 4, 2020
1 parent 9c4a78a commit 0b0a602
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions bin/ps/ps.c
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,7 @@ fmt(char **(*fn)(kvm_t *, const struct kinfo_proc *, int), KINFO *ki,
static void
saveuser(KINFO *ki)
{
char tdname[COMMLEN + 1];
char *argsp;

if (ki->ki_p->ki_flag & P_INMEM) {
Expand All @@ -1280,12 +1281,14 @@ saveuser(KINFO *ki)
* save arguments if needed
*/
if (needcomm) {
if (ki->ki_p->ki_stat == SZOMB)
if (ki->ki_p->ki_stat == SZOMB) {
ki->ki_args = strdup("<defunct>");
else if (UREADOK(ki) || (ki->ki_p->ki_args != NULL))
} else if (UREADOK(ki) || (ki->ki_p->ki_args != NULL)) {
(void)snprintf(tdname, sizeof(tdname), "%s%s",
ki->ki_p->ki_tdname, ki->ki_p->ki_moretdname);
ki->ki_args = fmt(kvm_getargv, ki,
ki->ki_p->ki_comm, ki->ki_p->ki_tdname, MAXCOMLEN);
else {
ki->ki_p->ki_comm, tdname, COMMLEN * 2 + 1);
} else {
asprintf(&argsp, "(%s)", ki->ki_p->ki_comm);
ki->ki_args = argsp;
}
Expand Down

0 comments on commit 0b0a602

Please sign in to comment.