diff options
author | trociny <trociny@FreeBSD.org> | 2013-04-20 08:05:04 +0000 |
---|---|---|
committer | trociny <trociny@FreeBSD.org> | 2013-04-20 08:05:04 +0000 |
commit | 7b0f0126fb247c7c74a8723dc794fc93445f2009 (patch) | |
tree | d4f59c0468456c7795ad92786bfeb50a267072db /usr.bin/procstat/procstat_bin.c | |
parent | 72dafce20f72d7aa3e2fab75a4ef453d39b8dbdd (diff) | |
download | FreeBSD-src-7b0f0126fb247c7c74a8723dc794fc93445f2009.zip FreeBSD-src-7b0f0126fb247c7c74a8723dc794fc93445f2009.tar.gz |
Use libprocstat(3) when retrieving binary information for a process.
MFC after: 1 month
Diffstat (limited to 'usr.bin/procstat/procstat_bin.c')
-rw-r--r-- | usr.bin/procstat/procstat_bin.c | 33 |
1 files changed, 6 insertions, 27 deletions
diff --git a/usr.bin/procstat/procstat_bin.c b/usr.bin/procstat/procstat_bin.c index 718103d..dc88c38 100644 --- a/usr.bin/procstat/procstat_bin.c +++ b/usr.bin/procstat/procstat_bin.c @@ -40,40 +40,19 @@ #include "procstat.h" void -procstat_bin(struct kinfo_proc *kipp) +procstat_bin(struct procstat *prstat, struct kinfo_proc *kipp) { - char pathname[PATH_MAX]; - int error, osrel, name[4]; - size_t len; + int osrel; + static char pathname[PATH_MAX]; if (!hflag) printf("%5s %-16s %8s %s\n", "PID", "COMM", "OSREL", "PATH"); - name[0] = CTL_KERN; - name[1] = KERN_PROC; - name[2] = KERN_PROC_PATHNAME; - name[3] = kipp->ki_pid; - - len = sizeof(pathname); - error = sysctl(name, 4, pathname, &len, NULL, 0); - if (error < 0 && errno != ESRCH) { - warn("sysctl: kern.proc.pathname: %d", kipp->ki_pid); - return; - } - if (error < 0) + if (procstat_getpathname(prstat, kipp, pathname, sizeof(pathname)) != 0) return; - if (len == 0 || strlen(pathname) == 0) + if (strlen(pathname) == 0) strcpy(pathname, "-"); - - name[2] = KERN_PROC_OSREL; - - len = sizeof(osrel); - error = sysctl(name, 4, &osrel, &len, NULL, 0); - if (error < 0 && errno != ESRCH) { - warn("sysctl: kern.proc.osrel: %d", kipp->ki_pid); - return; - } - if (error < 0) + if (procstat_getosrel(prstat, kipp, &osrel) != 0) return; printf("%5d ", kipp->ki_pid); |