Make procstat -l to work with the new version of kern.proc.rlimit.
Submitted by: Andrey Zonov <andrey at zonov.org> MFC after: 2 weeks
This commit is contained in:
parent
8854fe3915
commit
c3c314f9f7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=230471
@ -90,27 +90,28 @@ const char *humanize_rlimit(int indx, rlim_t limit)
|
||||
void
|
||||
procstat_rlimit(struct kinfo_proc *kipp)
|
||||
{
|
||||
int error, i, name[4];
|
||||
int error, i, name[5];
|
||||
size_t len;
|
||||
|
||||
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;
|
||||
len = sizeof(rlimit);
|
||||
error = sysctl(name, 4, rlimit, &len, NULL, 0);
|
||||
if (error < 0 && errno != ESRCH) {
|
||||
warn("sysctl: kern.proc.rlimit: %d", kipp->ki_pid);
|
||||
return;
|
||||
}
|
||||
if (error < 0 || len != sizeof(rlimit))
|
||||
return;
|
||||
|
||||
for (i = 0; i < RLIM_NLIMITS; i++) {
|
||||
name[4] = i;
|
||||
error = sysctl(name, 5, &rlimit[i], &len, NULL, 0);
|
||||
if (error < 0 && errno != ESRCH) {
|
||||
warn("sysctl: kern.proc.rlimit: %d", kipp->ki_pid);
|
||||
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[i].rlim_cur));
|
||||
|
Loading…
Reference in New Issue
Block a user