Use procstat_getrlimit(3) for retrieving rlimit information instead of
direct sysctl calls. MFC after: 1 month
This commit is contained in:
parent
398b48380f
commit
16576036c3
@ -73,7 +73,7 @@ procstat(struct procstat *prstat, struct kinfo_proc *kipp)
|
||||
else if (kflag)
|
||||
procstat_kstack(kipp, kflag);
|
||||
else if (lflag)
|
||||
procstat_rlimit(kipp);
|
||||
procstat_rlimit(prstat, kipp);
|
||||
else if (sflag)
|
||||
procstat_cred(prstat, kipp);
|
||||
else if (tflag)
|
||||
|
@ -42,7 +42,7 @@ void procstat_cred(struct procstat *prstat, struct kinfo_proc *kipp);
|
||||
void procstat_env(struct kinfo_proc *kipp);
|
||||
void procstat_files(struct procstat *prstat, struct kinfo_proc *kipp);
|
||||
void procstat_kstack(struct kinfo_proc *kipp, int kflag);
|
||||
void procstat_rlimit(struct kinfo_proc *kipp);
|
||||
void procstat_rlimit(struct procstat *prstat, struct kinfo_proc *kipp);
|
||||
void procstat_sigs(struct procstat *prstat, struct kinfo_proc *kipp);
|
||||
void procstat_threads(struct procstat *prstat, struct kinfo_proc *kipp);
|
||||
void procstat_threads_sigs(struct procstat *prstat, struct kinfo_proc *kipp);
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user