Deleted Added
full compact
26c26
< * $FreeBSD: head/usr.bin/procstat/procstat_rlimit.c 227956 2011-11-24 20:54:06Z trociny $
---
> * $FreeBSD: head/usr.bin/procstat/procstat_rlimit.c 228446 2011-12-12 21:41:05Z trociny $
31d30
< #define _RLIMIT_IDENT
38a38
> #include <libutil.h>
45a46,68
> static struct {
> const char *name;
> const char *suffix;
> } rlimit_param[13] = {
> {"cputime", "sec"},
> {"filesize", "B "},
> {"datasize", "B "},
> {"stacksize", "B "},
> {"coredumpsize", "B "},
> {"memoryuse", "B "},
> {"memorylocked", "B "},
> {"maxprocesses", " "},
> {"openfiles", " "},
> {"sbsize", "B "},
> {"vmemoryuse", "B "},
> {"pseudo-terminals", " "},
> {"swapuse", "B "},
> };
>
> #if RLIM_NLIMITS > 13
> #error "Resource limits have grown. Add new entries to rlimit_param[]."
> #endif
>
47a71,89
> static
> const char *humanize_rlimit(int indx, rlim_t limit)
> {
> static char buf[14];
> int scale;
>
> if (limit == RLIM_INFINITY)
> return ("infinity ");
>
> scale = humanize_number(buf, sizeof(buf) - 1, (int64_t)limit,
> rlimit_param[indx].suffix, HN_AUTOSCALE | HN_GETSCALE, HN_DECIMAL);
> (void)humanize_number(buf, sizeof(buf) - 1, (int64_t)limit,
> rlimit_param[indx].suffix, HN_AUTOSCALE, HN_DECIMAL);
> /* Pad with one space if there is no suffix prefix. */
> if (scale == 0)
> sprintf(buf + strlen(buf), " ");
> return (buf);
> }
>
54,56c96,99
< if (!hflag)
< printf("%5s %-16s %-10s %12s %12s\n", "PID", "COMM", "RLIMIT",
< "CURRENT", "MAX");
---
> if (!hflag) {
> printf("%5s %-16s %-16s %16s %16s\n",
> "PID", "COMM", "RLIMIT", "SOFT ", "HARD ");
> }
71,76c114,117
< printf("%5d %-16s %-10s %12jd %12jd\n", kipp->ki_pid,
< kipp->ki_comm, rlimit_ident[i],
< rlimit[i].rlim_cur == RLIM_INFINITY ?
< -1 : rlimit[i].rlim_cur,
< rlimit[i].rlim_max == RLIM_INFINITY ?
< -1 : rlimit[i].rlim_max);
---
> printf("%5d %-16s %-16s ", kipp->ki_pid, kipp->ki_comm,
> rlimit_param[i].name);
> printf("%16s ", humanize_rlimit(i, rlimit[i].rlim_cur));
> printf("%16s\n", humanize_rlimit(i, rlimit[i].rlim_max));