diff options
author | trociny <trociny@FreeBSD.org> | 2013-04-20 08:01:00 +0000 |
---|---|---|
committer | trociny <trociny@FreeBSD.org> | 2013-04-20 08:01:00 +0000 |
commit | 16576036c320aca798d2600c23fd16c95b499140 (patch) | |
tree | 963662d828d75069eb1b77898be035ef1c6f7f66 /usr.bin/procstat/procstat_rlimit.c | |
parent | 398b48380ff7b2ea5c997d18f7395b2aa9e36b06 (diff) | |
download | FreeBSD-src-16576036c320aca798d2600c23fd16c95b499140.zip FreeBSD-src-16576036c320aca798d2600c23fd16c95b499140.tar.gz |
Use procstat_getrlimit(3) for retrieving rlimit information instead of
direct sysctl calls.
MFC after: 1 month
Diffstat (limited to 'usr.bin/procstat/procstat_rlimit.c')
-rw-r--r-- | usr.bin/procstat/procstat_rlimit.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/usr.bin/procstat/procstat_rlimit.c b/usr.bin/procstat/procstat_rlimit.c index 68230e5..f3ed5fc 100644 --- a/usr.bin/procstat/procstat_rlimit.c +++ b/usr.bin/procstat/procstat_rlimit.c @@ -86,31 +86,18 @@ humanize_rlimit(int indx, rlim_t limit) } void -procstat_rlimit(struct kinfo_proc *kipp) +procstat_rlimit(struct procstat *prstat, struct kinfo_proc *kipp) { struct rlimit rlimit; - int error, i, name[5]; - size_t len; + int i; if (!hflag) { printf("%5s %-16s %-16s %16s %16s\n", "PID", "COMM", "RLIMIT", "SOFT ", "HARD "); } - len = sizeof(struct rlimit); - name[0] = CTL_KERN; - name[1] = KERN_PROC; - name[2] = KERN_PROC_RLIMIT; - name[3] = kipp->ki_pid; for (i = 0; i < RLIM_NLIMITS; i++) { - name[4] = i; - error = sysctl(name, 5, &rlimit, &len, NULL, 0); - if (error < 0 && errno != ESRCH) { - warn("sysctl: kern.proc.rlimit: %d", kipp->ki_pid); + if (procstat_getrlimit(prstat, kipp, i, &rlimit) == -1) return; - } - if (error < 0 || len != sizeof(struct rlimit)) - return; - printf("%5d %-16s %-16s ", kipp->ki_pid, kipp->ki_comm, rlimit_param[i].name); printf("%16s ", humanize_rlimit(i, rlimit.rlim_cur)); |