From owner-freebsd-bugs@FreeBSD.ORG Thu Nov 24 21:00:31 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0AE9C106564A for ; Thu, 24 Nov 2011 21:00:31 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id E3DE78FC16 for ; Thu, 24 Nov 2011 21:00:30 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id pAOL0U1b005738 for ; Thu, 24 Nov 2011 21:00:30 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id pAOL0UVE005737; Thu, 24 Nov 2011 21:00:30 GMT (envelope-from gnats) Date: Thu, 24 Nov 2011 21:00:30 GMT Message-Id: <201111242100.pAOL0UVE005737@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: dfilter@FreeBSD.ORG (dfilter service) Cc: Subject: Re: bin/161257: commit references a PR X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: dfilter service List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Nov 2011 21:00:31 -0000 The following reply was made to PR bin/161257; it has been noted by GNATS. From: dfilter@FreeBSD.ORG (dfilter service) To: bug-followup@FreeBSD.org Cc: Subject: Re: bin/161257: commit references a PR Date: Thu, 24 Nov 2011 20:54:15 +0000 (UTC) Author: trociny Date: Thu Nov 24 20:54:06 2011 New Revision: 227956 URL: http://svn.freebsd.org/changeset/base/227956 Log: usr.bin/procstat Add -l flag to display resource limits. PR: bin/161257 Reviewed by: kib MFC after: 2 weeks Added: head/usr.bin/procstat/procstat_rlimit.c (contents, props changed) Modified: head/usr.bin/procstat/Makefile head/usr.bin/procstat/procstat.1 head/usr.bin/procstat/procstat.c head/usr.bin/procstat/procstat.h Modified: head/usr.bin/procstat/Makefile ============================================================================== --- head/usr.bin/procstat/Makefile Thu Nov 24 20:43:37 2011 (r227955) +++ head/usr.bin/procstat/Makefile Thu Nov 24 20:54:06 2011 (r227956) @@ -10,6 +10,7 @@ SRCS= procstat.c \ procstat_cred.c \ procstat_files.c \ procstat_kstack.c \ + procstat_rlimit.c \ procstat_sigs.c \ procstat_threads.c \ procstat_vm.c Modified: head/usr.bin/procstat/procstat.1 ============================================================================== --- head/usr.bin/procstat/procstat.1 Thu Nov 24 20:43:37 2011 (r227955) +++ head/usr.bin/procstat/procstat.1 Thu Nov 24 20:54:06 2011 (r227956) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 22, 2011 +.Dd November 24, 2011 .Dt PROCSTAT 1 .Os .Sh NAME @@ -69,6 +69,8 @@ Display the stacks of kernel threads in threads currently running on a CPU and threads with stacks swapped to disk. If the flag is repeated, function offsets as well as function names are printed. +.It Fl l +Display resource limits for the process. .It Fl s Display security credential information for the process. .It Fl t Modified: head/usr.bin/procstat/procstat.c ============================================================================== --- head/usr.bin/procstat/procstat.c Thu Nov 24 20:43:37 2011 (r227955) +++ head/usr.bin/procstat/procstat.c Thu Nov 24 20:54:06 2011 (r227956) @@ -39,8 +39,8 @@ #include "procstat.h" -static int aflag, bflag, cflag, eflag, fflag, iflag, jflag, kflag, sflag, tflag; -static int vflag, xflag; +static int aflag, bflag, cflag, eflag, fflag, iflag, jflag, kflag, lflag, sflag; +static int tflag, vflag, xflag; int hflag, nflag, Cflag; static void @@ -50,7 +50,7 @@ usage(void) fprintf(stderr, "usage: procstat [-h] [-C] [-M core] [-N system] " "[-w interval] \n"); fprintf(stderr, " [-b | -c | -e | -f | -i | -j | -k | " - "-s | -t | -v | -x] [-a | pid ...]\n"); + "-l | -s | -t | -v | -x] [-a | pid ...]\n"); exit(EX_USAGE); } @@ -72,6 +72,8 @@ procstat(struct procstat *prstat, struct procstat_threads_sigs(prstat, kipp); else if (kflag) procstat_kstack(kipp, kflag); + else if (lflag) + procstat_rlimit(kipp); else if (sflag) procstat_cred(kipp); else if (tflag) @@ -123,7 +125,7 @@ main(int argc, char *argv[]) interval = 0; memf = nlistf = NULL; - while ((ch = getopt(argc, argv, "CN:M:abcefijkhstvw:x")) != -1) { + while ((ch = getopt(argc, argv, "CN:M:abcefijklhstvw:x")) != -1) { switch (ch) { case 'C': Cflag++; @@ -167,6 +169,10 @@ main(int argc, char *argv[]) kflag++; break; + case 'l': + lflag++; + break; + case 'n': nflag++; break; @@ -210,8 +216,8 @@ main(int argc, char *argv[]) argv += optind; /* We require that either 0 or 1 mode flags be set. */ - tmp = bflag + cflag + eflag + fflag + (kflag ? 1 : 0) + sflag + tflag + - vflag + xflag; + tmp = bflag + cflag + eflag + fflag + (kflag ? 1 : 0) + lflag + sflag + + tflag + vflag + xflag; if (!(tmp == 0 || tmp == 1)) usage(); Modified: head/usr.bin/procstat/procstat.h ============================================================================== --- head/usr.bin/procstat/procstat.h Thu Nov 24 20:43:37 2011 (r227955) +++ head/usr.bin/procstat/procstat.h Thu Nov 24 20:54:06 2011 (r227956) @@ -42,6 +42,7 @@ void procstat_cred(struct kinfo_proc *ki 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_sigs(struct procstat *prstat, struct kinfo_proc *kipp); void procstat_threads(struct kinfo_proc *kipp); void procstat_threads_sigs(struct procstat *prstat, struct kinfo_proc *kipp); Added: head/usr.bin/procstat/procstat_rlimit.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/procstat/procstat_rlimit.c Thu Nov 24 20:54:06 2011 (r227956) @@ -0,0 +1,78 @@ +/*- + * Copyright (c) 2011 Mikolaj Golub + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#define _RLIMIT_IDENT +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "procstat.h" + +static struct rlimit rlimit[RLIM_NLIMITS]; + +void +procstat_rlimit(struct kinfo_proc *kipp) +{ + int error, i, name[4]; + size_t len; + + if (!hflag) + printf("%5s %-16s %-10s %12s %12s\n", "PID", "COMM", "RLIMIT", + "CURRENT", "MAX"); + 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++) { + 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); + } +} _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"