Skip to content

Commit

Permalink
procstat auxv: widen COMM column to MAXCOMLEN
Browse files Browse the repository at this point in the history
For reasons unknown, procstat subcommands typically display the command
in a 16+overflow column format.  However, the command may be up to
MAXCOMLEN (19) characters long causing the column to spill into the next
one. Since there's plenty of room in the auxv case, bump the column
width up to 19 to avoid this issue.  While this is a format change 1)
users who want to parse the data should use libxo output and 2) this
makes it possible to parse reliably with cut.

Reviewed by:	markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42202
  • Loading branch information
brooksdavis committed Oct 16, 2023
1 parent 248fe3d commit 8f9f7b4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions usr.bin/procstat/procstat_auxv.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ procstat_auxv(struct procstat *procstat, struct kinfo_proc *kipp)
static char prefix[256];

if ((procstat_opts & PS_OPT_NOHEADER) == 0)
xo_emit("{T:/%5s %-16s %-16s %-16s}\n", "PID", "COMM", "AUXV",
xo_emit("{T:/%5s %-19s %-16s %-16s}\n", "PID", "COMM", "AUXV",
"VALUE");

auxv = procstat_getauxv(procstat, kipp, &count);
if (auxv == NULL)
return;
snprintf(prefix, sizeof(prefix), "%5d %-16s", kipp->ki_pid,
kipp->ki_comm);
snprintf(prefix, sizeof(prefix), "%5d %-19s", kipp->ki_pid,
kipp->ki_comm);

xo_emit("{e:process_id/%5d/%d}{e:command/%-16s/%s}", kipp->ki_pid,
xo_emit("{e:process_id/%5d/%d}{e:command/%-19s/%s}", kipp->ki_pid,
kipp->ki_comm);

for (i = 0; i < count; i++) {
Expand Down

0 comments on commit 8f9f7b4

Please sign in to comment.