Author: trociny
Date: Sat Apr 20 08:01:00 2013
New Revision: 249675
URL: http://svnweb.freebsd.org/changeset/base/249675

Log:
  Use procstat_getrlimit(3) for retrieving rlimit information instead of
  direct sysctl calls.
  
  MFC after:    1 month

Modified:
  head/usr.bin/procstat/procstat.c
  head/usr.bin/procstat/procstat.h
  head/usr.bin/procstat/procstat_rlimit.c

Modified: head/usr.bin/procstat/procstat.c
==============================================================================
--- head/usr.bin/procstat/procstat.c    Sat Apr 20 07:59:44 2013        
(r249674)
+++ head/usr.bin/procstat/procstat.c    Sat Apr 20 08:01:00 2013        
(r249675)
@@ -73,7 +73,7 @@ procstat(struct procstat *prstat, struct
        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)

Modified: head/usr.bin/procstat/procstat.h
==============================================================================
--- head/usr.bin/procstat/procstat.h    Sat Apr 20 07:59:44 2013        
(r249674)
+++ head/usr.bin/procstat/procstat.h    Sat Apr 20 08:01:00 2013        
(r249675)
@@ -42,7 +42,7 @@ void  procstat_cred(struct procstat *prst
 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);

Modified: head/usr.bin/procstat/procstat_rlimit.c
==============================================================================
--- head/usr.bin/procstat/procstat_rlimit.c     Sat Apr 20 07:59:44 2013        
(r249674)
+++ head/usr.bin/procstat/procstat_rlimit.c     Sat Apr 20 08:01:00 2013        
(r249675)
@@ -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));
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to