diff options
author | rwatson <rwatson@FreeBSD.org> | 2007-12-10 20:55:43 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2007-12-10 20:55:43 +0000 |
commit | 8bc41fcc02ff4a03b29c2a776d0866b0030bcdc2 (patch) | |
tree | d45a0b2693d7dfd7613ff915d2c1cc46c6ca0e8d | |
parent | 95c502771082069b023dca6ea4367751107e3d52 (diff) | |
download | FreeBSD-src-8bc41fcc02ff4a03b29c2a776d0866b0030bcdc2.zip FreeBSD-src-8bc41fcc02ff4a03b29c2a776d0866b0030bcdc2.tar.gz |
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.
-rw-r--r-- | usr.bin/procstat/procstat_args.c | 4 | ||||
-rw-r--r-- | usr.bin/procstat/procstat_bin.c | 4 | ||||
-rw-r--r-- | usr.bin/procstat/procstat_cred.c | 6 | ||||
-rw-r--r-- | usr.bin/procstat/procstat_files.c | 35 |
4 files changed, 29 insertions, 20 deletions
diff --git a/usr.bin/procstat/procstat_args.c b/usr.bin/procstat/procstat_args.c index f4a27a0..84da1d8 100644 --- a/usr.bin/procstat/procstat_args.c +++ b/usr.bin/procstat/procstat_args.c @@ -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"); diff --git a/usr.bin/procstat/procstat_bin.c b/usr.bin/procstat/procstat_bin.c index a6757eb..178d0a4 100644 --- a/usr.bin/procstat/procstat_bin.c +++ b/usr.bin/procstat/procstat_bin.c @@ -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); } diff --git a/usr.bin/procstat/procstat_cred.c b/usr.bin/procstat/procstat_cred.c index a1fc89b..82ac6ad 100644 --- a/usr.bin/procstat/procstat_cred.c +++ b/usr.bin/procstat/procstat_cred.c @@ -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); diff --git a/usr.bin/procstat/procstat_files.c b/usr.bin/procstat/procstat_files.c index e36fc01..9fcb1fd 100644 --- a/usr.bin/procstat/procstat_files.c +++ b/usr.bin/procstat/procstat_files.c @@ -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"); |