Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/procstat/procstat_rlimit.c
/*- | /*- | ||||
* Copyright (c) 2011 Mikolaj Golub | * Copyright (c) 2011 Mikolaj Golub | ||||
* Copyright (c) 2015 Allan Jude <allanjude@freebsd.org> | |||||
* All rights reserved. | * All rights reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | ||||
* are met: | * are met: | ||||
* 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | ||||
* notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer. | ||||
* 2. Redistributions in binary form must reproduce the above copyright | * 2. Redistributions in binary form must reproduce the above copyright | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | |||||
void | void | ||||
procstat_rlimit(struct procstat *prstat, struct kinfo_proc *kipp) | procstat_rlimit(struct procstat *prstat, struct kinfo_proc *kipp) | ||||
{ | { | ||||
struct rlimit rlimit; | struct rlimit rlimit; | ||||
int i; | int i; | ||||
if (!hflag) { | if (!hflag) { | ||||
printf("%5s %-16s %-16s %16s %16s\n", | xo_emit("{T:/%5s %-16s %-16s %16s %16s}\n", | ||||
"PID", "COMM", "RLIMIT", "SOFT ", "HARD "); | "PID", "COMM", "RLIMIT", "SOFT ", "HARD "); | ||||
} | } | ||||
xo_emit("{ek:process_id/%5d}{e:command/%-16s/%s}", kipp->ki_pid, | |||||
kipp->ki_comm); | |||||
for (i = 0; i < RLIM_NLIMITS; i++) { | for (i = 0; i < RLIM_NLIMITS; i++) { | ||||
if (procstat_getrlimit(prstat, kipp, i, &rlimit) == -1) | if (procstat_getrlimit(prstat, kipp, i, &rlimit) == -1) | ||||
return; | return; | ||||
printf("%5d %-16s %-16s ", kipp->ki_pid, kipp->ki_comm, | xo_emit("{dk:process_id/%5d} {d:command/%-16s} " | ||||
"{d:rlimit_param/%-16s} ", kipp->ki_pid, kipp->ki_comm, | |||||
rlimit_param[i].name); | rlimit_param[i].name); | ||||
printf("%16s ", humanize_rlimit(i, rlimit.rlim_cur)); | |||||
printf("%16s\n", humanize_rlimit(i, rlimit.rlim_max)); | xo_open_container(rlimit_param[i].name); | ||||
if (rlimit.rlim_cur == RLIM_INFINITY) | |||||
xo_emit("{e:soft_limit/infinity}"); | |||||
else | |||||
xo_emit("{e:soft_limit/%U}", rlimit.rlim_cur); | |||||
if (rlimit.rlim_max == RLIM_INFINITY) | |||||
xo_emit("{e:hard_limit/infinity}"); | |||||
else | |||||
xo_emit("{e:hard_limit/%U}", rlimit.rlim_max); | |||||
xo_close_container(rlimit_param[i].name); | |||||
xo_emit("{d:rlim_cur/%16s} ", | |||||
humanize_rlimit(i, rlimit.rlim_cur)); | |||||
xo_emit("{d:rlim_max/%16s}\n", | |||||
humanize_rlimit(i, rlimit.rlim_max)); | |||||
} | } | ||||
} | } |