Add 'COMM' column to a few more output modes of procstat(1). The only
one it's missing from is the VM display, where there's really not room, and the file output display is looking quite cramped.
This commit is contained in:
parent
0a63574164
commit
5a246d2912
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/user.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
|
@ -48,7 +49,7 @@ procstat_args(pid_t pid, struct kinfo_proc *kipp)
|
|||
char *cp;
|
||||
|
||||
if (!hflag)
|
||||
printf("%5s %-70s\n", "PID", "ARGS");
|
||||
printf("%5s %-16s %-53s\n", "PID", "COMM", "ARGS");
|
||||
|
||||
name[0] = CTL_KERN;
|
||||
name[1] = KERN_PROC;
|
||||
|
@ -68,6 +69,7 @@ procstat_args(pid_t pid, struct kinfo_proc *kipp)
|
|||
}
|
||||
|
||||
printf("%5d ", pid);
|
||||
printf("%-16s ", kipp->ki_comm);
|
||||
for (cp = args; cp < args + len; cp += strlen(cp) + 1)
|
||||
printf("%s%s", cp != args ? " " : "", cp);
|
||||
printf("\n");
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/user.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
|
@ -45,7 +46,7 @@ procstat_bin(pid_t pid, struct kinfo_proc *kipp)
|
|||
size_t len;
|
||||
|
||||
if (!hflag)
|
||||
printf("%5s %-70s\n", "PID", "PATH");
|
||||
printf("%5s %-16s %-53s\n", "PID", "COMM", "PATH");
|
||||
|
||||
name[0] = CTL_KERN;
|
||||
name[1] = KERN_PROC;
|
||||
|
@ -64,5 +65,6 @@ procstat_bin(pid_t pid, struct kinfo_proc *kipp)
|
|||
strcpy(pathname, "-");
|
||||
|
||||
printf("%5d ", pid);
|
||||
printf("%-16s ", kipp->ki_comm);
|
||||
printf("%s\n", pathname);
|
||||
}
|
||||
|
|
|
@ -41,10 +41,12 @@ procstat_cred(pid_t pid, struct kinfo_proc *kipp)
|
|||
int i;
|
||||
|
||||
if (!hflag)
|
||||
printf("%5s %5s %5s %5s %5s %5s %5s %-20s\n", "PID", "EUID",
|
||||
"RUID", "SVUID", "EGID", "RGID", "SVGID", "GROUPS");
|
||||
printf("%5s %-16s %5s %5s %5s %5s %5s %5s %-20s\n", "PID",
|
||||
"COMM", "EUID", "RUID", "SVUID", "EGID", "RGID", "SVGID",
|
||||
"GROUPS");
|
||||
|
||||
printf("%5d ", pid);
|
||||
printf("%-16s ", kipp->ki_comm);
|
||||
printf("%5d ", kipp->ki_uid);
|
||||
printf("%5d ", kipp->ki_ruid);
|
||||
printf("%5d ", kipp->ki_svuid);
|
||||
|
|
|
@ -57,26 +57,28 @@ protocol_to_string(int domain, int type, int protocol)
|
|||
case IPPROTO_UDP:
|
||||
return ("UDP");
|
||||
case IPPROTO_ICMP:
|
||||
return ("ICMP");
|
||||
return ("ICM");
|
||||
case IPPROTO_RAW:
|
||||
return ("RAW");
|
||||
case IPPROTO_SCTP:
|
||||
return ("SCTP");
|
||||
return ("SCT");
|
||||
case IPPROTO_DIVERT:
|
||||
return ("IPD");
|
||||
default:
|
||||
return ("??");
|
||||
return ("IP?");
|
||||
}
|
||||
|
||||
case AF_LOCAL:
|
||||
switch (type) {
|
||||
case SOCK_STREAM:
|
||||
return ("UDSS");
|
||||
return ("UDS");
|
||||
case SOCK_DGRAM:
|
||||
return ("UDSD");
|
||||
return ("UDD");
|
||||
default:
|
||||
return ("??");
|
||||
return ("UD?");
|
||||
}
|
||||
default:
|
||||
return ("??");
|
||||
return ("?");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,7 +127,7 @@ print_address(struct sockaddr_storage *ss)
|
|||
char addr[PATH_MAX];
|
||||
|
||||
addr_to_string(ss, addr, sizeof(addr));
|
||||
printf("%-19s", addr);
|
||||
printf("%s", addr);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -137,9 +139,9 @@ procstat_files(pid_t pid, struct kinfo_proc *kipp)
|
|||
size_t len;
|
||||
|
||||
if (!hflag)
|
||||
printf("%5s %3s %1s %1s %-8s %3s %7s %-4s %-35s\n", "PID",
|
||||
"FD", "T", "V", "FLAGS", "REF", "OFFSET", "PROT",
|
||||
"NAME");
|
||||
printf("%5s %-16s %3s %1s %1s %-8s %3s %7s %-3s %-12s\n",
|
||||
"PID", "COMM", "FD", "T", "V", "FLAGS", "REF", "OFFSET",
|
||||
"PRO", "NAME");
|
||||
|
||||
name[0] = CTL_KERN;
|
||||
name[1] = KERN_PROC;
|
||||
|
@ -168,6 +170,7 @@ procstat_files(pid_t pid, struct kinfo_proc *kipp)
|
|||
if (kif->kf_structsize != sizeof(*kif))
|
||||
errx(-1, "kinfo_file mismatch");
|
||||
printf("%5d ", pid);
|
||||
printf("%-16s ", kipp->ki_comm);
|
||||
printf("%3d ", kif->kf_fd);
|
||||
switch (kif->kf_type) {
|
||||
case KF_TYPE_VNODE:
|
||||
|
@ -262,12 +265,12 @@ procstat_files(pid_t pid, struct kinfo_proc *kipp)
|
|||
switch (kif->kf_type) {
|
||||
case KF_TYPE_VNODE:
|
||||
case KF_TYPE_FIFO:
|
||||
printf("%-4s ", "-");
|
||||
printf("%-35s", kif->kf_path);
|
||||
printf("%-3s ", "-");
|
||||
printf("%-18s", kif->kf_path);
|
||||
break;
|
||||
|
||||
case KF_TYPE_SOCKET:
|
||||
printf("%-4s ",
|
||||
printf("%-3s ",
|
||||
protocol_to_string(kif->kf_sock_domain,
|
||||
kif->kf_sock_type, kif->kf_sock_protocol));
|
||||
/*
|
||||
|
@ -293,8 +296,8 @@ procstat_files(pid_t pid, struct kinfo_proc *kipp)
|
|||
break;
|
||||
|
||||
default:
|
||||
printf("%-4s ", "-");
|
||||
printf("%-35s", "-");
|
||||
printf("%-3s ", "-");
|
||||
printf("%-18s", "-");
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
|
Loading…
Reference in New Issue