[Midnightbsd-cvs] src [11450] trunk/usr.bin/procstat: sync procstat with freebsd
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Jul 7 12:43:36 EDT 2018
Revision: 11450
http://svnweb.midnightbsd.org/src/?rev=11450
Author: laffer1
Date: 2018-07-07 12:43:35 -0400 (Sat, 07 Jul 2018)
Log Message:
-----------
sync procstat with freebsd
Modified Paths:
--------------
trunk/usr.bin/procstat/Makefile
trunk/usr.bin/procstat/procstat.1
trunk/usr.bin/procstat/procstat.c
trunk/usr.bin/procstat/procstat.h
trunk/usr.bin/procstat/procstat_args.c
trunk/usr.bin/procstat/procstat_auxv.c
trunk/usr.bin/procstat/procstat_basic.c
trunk/usr.bin/procstat/procstat_bin.c
trunk/usr.bin/procstat/procstat_cred.c
trunk/usr.bin/procstat/procstat_files.c
trunk/usr.bin/procstat/procstat_kstack.c
trunk/usr.bin/procstat/procstat_rlimit.c
trunk/usr.bin/procstat/procstat_sigs.c
trunk/usr.bin/procstat/procstat_threads.c
trunk/usr.bin/procstat/procstat_vm.c
Added Paths:
-----------
trunk/usr.bin/procstat/procstat_cs.c
trunk/usr.bin/procstat/procstat_rusage.c
trunk/usr.bin/procstat/tests/
trunk/usr.bin/procstat/tests/Makefile
trunk/usr.bin/procstat/tests/procstat_test.sh
trunk/usr.bin/procstat/tests/while1.c
Property Changed:
----------------
trunk/usr.bin/procstat/procstat.1
Modified: trunk/usr.bin/procstat/Makefile
===================================================================
--- trunk/usr.bin/procstat/Makefile 2018-07-07 16:42:22 UTC (rev 11449)
+++ trunk/usr.bin/procstat/Makefile 2018-07-07 16:43:35 UTC (rev 11450)
@@ -1,5 +1,8 @@
# $MidnightBSD$
+# $FreeBSD: stable/10/usr.bin/procstat/Makefile 321084 2017-07-17 20:57:38Z ngie $
+.include <bsd.own.mk>
+
PROG= procstat
MAN= procstat.1
SRCS= procstat.c \
@@ -8,14 +11,20 @@
procstat_basic.c \
procstat_bin.c \
procstat_cred.c \
+ procstat_cs.c \
procstat_files.c \
procstat_kstack.c \
procstat_rlimit.c \
+ procstat_rusage.c \
procstat_sigs.c \
procstat_threads.c \
procstat_vm.c
LDADD+= -lutil -lprocstat -lkvm
-DPADD+= ${LIBUTIL}
+DPADD+= ${LIBUTIL} ${LIBPROCSTAT} ${LIBKVM}
+.if ${MK_TESTS} != "no"
+SUBDIR+= tests
+.endif
+
.include <bsd.prog.mk>
Modified: trunk/usr.bin/procstat/procstat.1
===================================================================
--- trunk/usr.bin/procstat/procstat.1 2018-07-07 16:42:22 UTC (rev 11449)
+++ trunk/usr.bin/procstat/procstat.1 2018-07-07 16:43:35 UTC (rev 11450)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\"-
.\" Copyright (c) 2007-2009 Robert N. M. Watson
.\" All rights reserved.
@@ -23,9 +24,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.bin/procstat/procstat.1 328422 2018-01-26 00:35:33Z brooks $
.\"
-.Dd April 20, 2013
+.Dd May 11, 2017
.Dt PROCSTAT 1
.Os
.Sh NAME
@@ -33,11 +34,9 @@
.Nd get detailed process information
.Sh SYNOPSIS
.Nm
-.Op Fl h
-.Op Fl n
-.Op Fl C
+.Op Fl CHhn
.Op Fl w Ar interval
-.Op Fl b | c | e | f | i | j | k | l | s | t | v | x
+.Op Fl b | c | e | f | i | j | k | l | r | s | S | t | v | x
.Op Fl a | Ar pid | Ar core ...
.Sh DESCRIPTION
The
@@ -65,7 +64,7 @@
.It Fl i
Display signal pending and disposition information for the process.
.It Fl j
-Display signal pending and blocked information for the process threads.
+Display signal pending and blocked information for the process's threads.
.It Fl k
Display the stacks of kernel threads in the process, excluding stacks of
threads currently running on a CPU and threads with stacks swapped to disk.
@@ -73,8 +72,12 @@
printed.
.It Fl l
Display resource limits for the process.
+.It Fl r
+Display resource usage information for the process.
.It Fl s
Display security credential information for the process.
+.It Fl S
+Display the cpuset information for the thread.
.It Fl t
Display thread information for the process.
.It Fl v
@@ -102,8 +105,22 @@
flag requests the printing of additional capability information in the file
descriptor view.
.Pp
-Some information, such as VM and file descriptor information, is available
+The
+.Fl H
+flag may be used to request per-thread statistics rather than per-process
+statistics for some options.
+For those options, the second field in the table will list the thread ID
+to which the row of information corresponds.
+The
+.Fl H
+flag is implied for the
+.Fl S
+mode.
+.Pp
+Information for VM, file descriptor, and cpuset options is available
only to the owner of a process or the superuser.
+A cpuset value displayed as -1 means that the information is either invalid
+or not available.
.Ss Binary Information
Display the process ID, command, and path to the process binary:
.Pp
@@ -128,6 +145,17 @@
.It ARGS
command line arguments (if available)
.El
+.Ss Environment Variables
+Display the process ID, command, and environment variables:
+.Pp
+.Bl -tag -width "ENVIRONMENT" -compact
+.It PID
+process ID
+.It COMM
+command
+.It ENVIRONMENT
+environment variables (if available)
+.El
.Ss File Descriptors
Display detailed information about each file descriptor referenced by a
process, including the process ID, command, file descriptor number, and
@@ -225,8 +253,6 @@
direct I/O
.It l
lock held
-.It c
-descriptor is a capability
.El
.Pp
If the
@@ -234,12 +260,66 @@
flag is specified, the vnode type, reference count, and offset fields will be
omitted, and a new capabilities field will be included listing capabilities,
as described in
-.Xr cap_new 2 ,
+.Xr cap_rights_limit 2 ,
present for each capability descriptor.
+.Pp
+The following network protocols may be displayed (grouped by address family):
+.Pp
+.Dv AF_INET ,
+.Dv AF_INET6
+.Pp
+.Bl -tag -width indent -compact
+.It ICM
+.Dv IPPROTO_ICMP ;
+see
+.Xr icmp 4 .
+.It IPD
+.Dv IPPROTO_DIVERT ;
+see
+.Xr divert 4 .
+.It IP?
+unknown protocol.
+.It RAW
+.Dv IPPROTO_RAW ;
+see
+.Xr ip 4 .
+.It SCT
+.Dv IPPROTO_SCTP ;
+see
+.Xr sctp 4 .
+.It TCP
+.Dv IPPROTO_TCP ;
+see
+.Xr tcp 4 .
+.It UDP
+.Dv IPPROTO_UDP ;
+see
+.Xr udp 4 .
+.El
+.Pp
+.Dv AF_LOCAL
+.Pp
+.Bl -tag -width indent -compact
+.It UDD
+.Dv IPPROTO_UDP ;
+see
+.Xr udp 4 .
+.It UDS
+.Dv IPPROTO_TCP ;
+see
+.Xr tcp 4 .
+.It UD?
+unknown protocol.
+.El
+.Pp
+.Bl -tag -width indent -compact
+.It ?
+unknown address family.
+.El
.Ss Signal Disposition Information
Display signal pending and disposition for a process:
.Pp
-.Bl -tag -width ident -compact
+.Bl -tag -width indent -compact
.It PID
process ID
.It COMM
@@ -250,11 +330,13 @@
process signal disposition details, three symbols
.Bl -tag -width X -compact
.It P
-if signal is pending in the global process queue, - otherwise
+if signal is pending in the global process queue; - otherwise.
.It I
-if signal delivery disposition is SIGIGN, - otherwise
+if signal delivery disposition is
+.Dv SIG_IGN;
+- otherwise.
.It C
-if signal delivery is to catch it, - otherwise
+if the signal will be caught; - otherwise.
.El
.El
.Pp
@@ -262,15 +344,15 @@
.Fl n
switch is given, the signal numbers are shown instead of signal names.
.Ss Thread Signal Information
-Display signal pending and blocked for a process threads:
+Display signal pending and blocked for a process's threads:
.Pp
-.Bl -tag -width ident -compact
+.Bl -tag -width indent -compact
.It PID
process ID
+.It TID
+thread ID
.It COMM
command
-.It TID
-thread ID
.It SIG
signal name
.It FLAGS
@@ -287,7 +369,7 @@
.Fl n
switch has the same effect as for the
.Fl i
-switch, the signals numbers are shown instead of signal names.
+switch: the signal numbers are shown instead of signal names.
.Ss Kernel Thread Stacks
Display kernel thread stacks for a process, allowing further interpretation
of thread wait channels.
@@ -313,6 +395,45 @@
.It KSTACK
kernel thread call stack
.El
+.Ss Resource Limits
+Display resource limits for a process:
+.Pp
+.Bl -tag -width indent -compact
+.It PID
+process ID
+.It COMM
+command
+.It RLIMIT
+resource limit name
+.It SOFT
+soft limit
+.It HARD
+hard limit
+.El
+.Ss Resource Usage
+Display resource usage for a process.
+If the
+.Fl H
+flag is specified,
+resource usage for individual threads is displayed instead.
+.Pp
+.Bl -tag -width "RESOURCE" -compact
+.It PID
+process ID
+.It TID
+thread ID
+.Po
+if
+.Fl H
+is specified
+.Pc
+.It COMM
+command
+.It RESOURCE
+resource name
+.It VALUE
+current usage
+.El
.Ss Security Credentials
Display process credential information:
.Pp
@@ -418,6 +539,9 @@
default
.It dv
device
+.It md
+device with managed pages
+.Pq GEM/TTM
.It ph
physical
.It sg
@@ -442,6 +566,19 @@
.It U
grows up (bottom-up stack)
.El
+.Ss ELF Auxiliary Vector
+Display ELF auxiliary vector values:
+.Pp
+.Bl -tag -width indent -compact
+.It PID
+process ID
+.It COMM
+command
+.It AUXV
+auxiliary vector name
+.It VALUE
+auxiliary vector value
+.El
.Sh EXIT STATUS
.Ex -std
.Sh SEE ALSO
@@ -449,8 +586,15 @@
.Xr ps 1 ,
.Xr sockstat 1 ,
.Xr cap_enter 2 ,
-.Xr cap_new 2 ,
+.Xr cap_rights_limit 2 ,
+.Xr signal 3 ,
.Xr ddb 4 ,
+.Xr divert 4 ,
+.Xr icmp 4 ,
+.Xr ip 4 ,
+.Xr sctp 4 ,
+.Xr tcp 4 ,
+.Xr udp 4 ,
.Xr stack 9
.Sh AUTHORS
.An Robert N M Watson
Property changes on: trunk/usr.bin/procstat/procstat.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/procstat/procstat.c
===================================================================
--- trunk/usr.bin/procstat/procstat.c 2018-07-07 16:42:22 UTC (rev 11449)
+++ trunk/usr.bin/procstat/procstat.c 2018-07-07 16:43:35 UTC (rev 11450)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2007, 2011 Robert N. M. Watson
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/procstat/procstat.c 310121 2016-12-15 16:52:17Z vangyzen $
*/
#include <sys/param.h>
@@ -34,23 +35,25 @@
#include <libprocstat.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <sysexits.h>
#include <unistd.h>
#include "procstat.h"
-static int aflag, bflag, cflag, eflag, fflag, iflag, jflag, kflag, lflag, sflag;
-static int tflag, vflag, xflag;
-int hflag, nflag, Cflag;
+static int aflag, bflag, cflag, eflag, fflag, iflag, jflag, kflag, lflag, rflag;
+static int sflag, tflag, vflag, xflag, Sflag;
+int hflag, nflag, Cflag, Hflag;
static void
usage(void)
{
- fprintf(stderr, "usage: procstat [-h] [-C] [-M core] [-N system] "
+ fprintf(stderr, "usage: procstat [-CHhn] [-M core] [-N system] "
"[-w interval] \n");
fprintf(stderr, " [-b | -c | -e | -f | -i | -j | -k | "
- "-l | -s | -t | -v | -x] [-a | pid | core ...]\n");
+ "-l | -r | -s | -S | -t | -v | -x]\n");
+ fprintf(stderr, " [-a | pid | core ...]\n");
exit(EX_USAGE);
}
@@ -74,6 +77,8 @@
procstat_kstack(prstat, kipp, kflag);
else if (lflag)
procstat_rlimit(prstat, kipp);
+ else if (rflag)
+ procstat_rusage(prstat, kipp);
else if (sflag)
procstat_cred(prstat, kipp);
else if (tflag)
@@ -82,6 +87,8 @@
procstat_vm(prstat, kipp);
else if (xflag)
procstat_auxv(prstat, kipp);
+ else if (Sflag)
+ procstat_cs(prstat, kipp);
else
procstat_basic(kipp);
}
@@ -110,6 +117,21 @@
qsort(kipp, count, sizeof(*kipp), kinfo_proc_compare);
}
+const char *
+kinfo_proc_thread_name(const struct kinfo_proc *kipp)
+{
+ static char name[MAXCOMLEN+1];
+
+ strlcpy(name, kipp->ki_tdname, sizeof(name));
+ strlcat(name, kipp->ki_moretdname, sizeof(name));
+ if (name[0] == '\0' || strcmp(kipp->ki_comm, name) == 0) {
+ name[0] = '-';
+ name[1] = '\0';
+ }
+
+ return (name);
+}
+
int
main(int argc, char *argv[])
{
@@ -125,12 +147,16 @@
interval = 0;
memf = nlistf = NULL;
- while ((ch = getopt(argc, argv, "CN:M:abcefijklhstvw:x")) != -1) {
+ while ((ch = getopt(argc, argv, "CHN:M:abcefijklhrsStvw:x")) != -1) {
switch (ch) {
case 'C':
Cflag++;
break;
+ case 'H':
+ Hflag++;
+ break;
+
case 'M':
memf = optarg;
break;
@@ -137,6 +163,9 @@
case 'N':
nlistf = optarg;
break;
+ case 'S':
+ Sflag++;
+ break;
case 'a':
aflag++;
break;
@@ -181,6 +210,10 @@
hflag++;
break;
+ case 'r':
+ rflag++;
+ break;
+
case 's':
sflag++;
break;
@@ -217,7 +250,7 @@
/* We require that either 0 or 1 mode flags be set. */
tmp = bflag + cflag + eflag + fflag + iflag + jflag + (kflag ? 1 : 0) +
- lflag + sflag + tflag + vflag + xflag;
+ lflag + rflag + sflag + tflag + vflag + xflag + Sflag;
if (!(tmp == 0 || tmp == 1))
usage();
Modified: trunk/usr.bin/procstat/procstat.h
===================================================================
--- trunk/usr.bin/procstat/procstat.h 2018-07-07 16:42:22 UTC (rev 11449)
+++ trunk/usr.bin/procstat/procstat.h 2018-07-07 16:43:35 UTC (rev 11450)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2007 Robert N. M. Watson
* All rights reserved.
@@ -23,16 +24,17 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/procstat/procstat.h 310121 2016-12-15 16:52:17Z vangyzen $
*/
#ifndef PROCSTAT_H
#define PROCSTAT_H
-extern int hflag, nflag, Cflag;
+extern int hflag, nflag, Cflag, Hflag;
struct kinfo_proc;
void kinfo_proc_sort(struct kinfo_proc *kipp, int count);
+const char * kinfo_proc_thread_name(const struct kinfo_proc *kipp);
void procstat_args(struct procstat *prstat, struct kinfo_proc *kipp);
void procstat_auxv(struct procstat *prstat, struct kinfo_proc *kipp);
@@ -39,11 +41,13 @@
void procstat_basic(struct kinfo_proc *kipp);
void procstat_bin(struct procstat *prstat, struct kinfo_proc *kipp);
void procstat_cred(struct procstat *prstat, struct kinfo_proc *kipp);
+void procstat_cs(struct procstat *prstat, struct kinfo_proc *kipp);
void procstat_env(struct procstat *prstat, struct kinfo_proc *kipp);
void procstat_files(struct procstat *prstat, struct kinfo_proc *kipp);
void procstat_kstack(struct procstat *prstat, struct kinfo_proc *kipp,
int kflag);
void procstat_rlimit(struct procstat *prstat, struct kinfo_proc *kipp);
+void procstat_rusage(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: trunk/usr.bin/procstat/procstat_args.c
===================================================================
--- trunk/usr.bin/procstat/procstat_args.c 2018-07-07 16:42:22 UTC (rev 11449)
+++ trunk/usr.bin/procstat/procstat_args.c 2018-07-07 16:43:35 UTC (rev 11450)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2007 Robert N. M. Watson
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/procstat/procstat_args.c 249680 2013-04-20 08:08:29Z trociny $
*/
#include <sys/param.h>
Modified: trunk/usr.bin/procstat/procstat_auxv.c
===================================================================
--- trunk/usr.bin/procstat/procstat_auxv.c 2018-07-07 16:42:22 UTC (rev 11449)
+++ trunk/usr.bin/procstat/procstat_auxv.c 2018-07-07 16:43:35 UTC (rev 11450)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2011 Mikolaj Golub
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/procstat/procstat_auxv.c 249683 2013-04-20 08:15:43Z trociny $
*/
#include <sys/param.h>
Modified: trunk/usr.bin/procstat/procstat_basic.c
===================================================================
--- trunk/usr.bin/procstat/procstat_basic.c 2018-07-07 16:42:22 UTC (rev 11449)
+++ trunk/usr.bin/procstat/procstat_basic.c 2018-07-07 16:43:35 UTC (rev 11450)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2007 Robert N. M. Watson
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/procstat/procstat_basic.c 221807 2011-05-12 10:11:39Z stas $
*/
#include <sys/param.h>
Modified: trunk/usr.bin/procstat/procstat_bin.c
===================================================================
--- trunk/usr.bin/procstat/procstat_bin.c 2018-07-07 16:42:22 UTC (rev 11449)
+++ trunk/usr.bin/procstat/procstat_bin.c 2018-07-07 16:43:35 UTC (rev 11450)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2007 Robert N. M. Watson
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/procstat/procstat_bin.c 249678 2013-04-20 08:05:04Z trociny $
*/
#include <sys/param.h>
Modified: trunk/usr.bin/procstat/procstat_cred.c
===================================================================
--- trunk/usr.bin/procstat/procstat_cred.c 2018-07-07 16:42:22 UTC (rev 11449)
+++ trunk/usr.bin/procstat/procstat_cred.c 2018-07-07 16:43:35 UTC (rev 11450)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2007-2008 Robert N. M. Watson
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/procstat/procstat_cred.c 249673 2013-04-20 07:58:20Z trociny $
*/
#include <sys/param.h>
Added: trunk/usr.bin/procstat/procstat_cs.c
===================================================================
--- trunk/usr.bin/procstat/procstat_cs.c (rev 0)
+++ trunk/usr.bin/procstat/procstat_cs.c 2018-07-07 16:43:35 UTC (rev 11450)
@@ -0,0 +1,107 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2007 Robert N. M. Watson
+ * 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: stable/10/usr.bin/procstat/procstat_cs.c 310121 2016-12-15 16:52:17Z vangyzen $
+ */
+
+#include <sys/param.h>
+#include <sys/cpuset.h>
+#include <sys/sysctl.h>
+#include <sys/user.h>
+
+#include <err.h>
+#include <errno.h>
+#include <libprocstat.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "procstat.h"
+
+void
+procstat_cs(struct procstat *procstat, struct kinfo_proc *kipp)
+{
+ cpusetid_t cs;
+ cpuset_t mask;
+ struct kinfo_proc *kip;
+ unsigned int count, i;
+ int once, twice, lastcpu, cpu;
+
+ if (!hflag)
+ printf("%5s %6s %-19s %-19s %2s %4s %-7s\n", "PID",
+ "TID", "COMM", "TDNAME", "CPU", "CSID", "CPU MASK");
+
+ kip = procstat_getprocs(procstat, KERN_PROC_PID | KERN_PROC_INC_THREAD,
+ kipp->ki_pid, &count);
+ if (kip == NULL)
+ return;
+ kinfo_proc_sort(kip, count);
+ for (i = 0; i < count; i++) {
+ kipp = &kip[i];
+ printf("%5d ", kipp->ki_pid);
+ printf("%6d ", kipp->ki_tid);
+ printf("%-19s ", strlen(kipp->ki_comm) ?
+ kipp->ki_comm : "-");
+ printf("%-19s ", kinfo_proc_thread_name(kipp));
+ if (kipp->ki_oncpu != 255)
+ printf("%3d ", kipp->ki_oncpu);
+ else if (kipp->ki_lastcpu != 255)
+ printf("%3d ", kipp->ki_lastcpu);
+ else
+ printf("%3s ", "-");
+ if (cpuset_getid(CPU_LEVEL_CPUSET, CPU_WHICH_TID,
+ kipp->ki_tid, &cs) != 0) {
+ cs = CPUSET_INVALID;
+ }
+ printf("%4d ", cs);
+ if ((cs != CPUSET_INVALID) &&
+ (cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID,
+ kipp->ki_tid, sizeof(mask), &mask) == 0)) {
+ lastcpu = -1;
+ once = 0;
+ twice = 0;
+ for (cpu = 0; cpu < CPU_SETSIZE; cpu++) {
+ if (CPU_ISSET(cpu, &mask)) {
+ if (once == 0) {
+ printf("%d", cpu);
+ once = 1;
+ } else if (cpu == lastcpu + 1) {
+ twice = 1;
+ } else if (twice == 1) {
+ printf("-%d,%d", lastcpu, cpu);
+ twice = 0;
+ } else
+ printf(",%d", cpu);
+ lastcpu = cpu;
+ }
+ }
+ if (once && twice)
+ printf("-%d", lastcpu);
+ }
+ printf("\n");
+ }
+ procstat_freeprocs(procstat, kip);
+}
Property changes on: trunk/usr.bin/procstat/procstat_cs.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/usr.bin/procstat/procstat_files.c
===================================================================
--- trunk/usr.bin/procstat/procstat_files.c 2018-07-07 16:42:22 UTC (rev 11449)
+++ trunk/usr.bin/procstat/procstat_files.c 2018-07-07 16:43:35 UTC (rev 11450)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2007-2011 Robert N. M. Watson
* All rights reserved.
@@ -23,11 +24,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/procstat/procstat_files.c 280250 2015-03-19 12:32:48Z rwatson $
*/
#include <sys/param.h>
-#include <sys/capability.h>
+#include <sys/capsicum.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <sys/un.h>
@@ -114,7 +115,7 @@
snprintf(buffer, buflen, "%s.%d", buffer2,
ntohs(sin6->sin6_port));
else
- strlcpy(buffer, "-", sizeof(buffer));
+ strlcpy(buffer, "-", buflen);
break;
default:
@@ -133,38 +134,40 @@
}
static struct cap_desc {
- cap_rights_t cd_right;
+ uint64_t cd_right;
const char *cd_desc;
} cap_desc[] = {
/* General file I/O. */
{ CAP_READ, "rd" },
{ CAP_WRITE, "wr" },
+ { CAP_SEEK, "se" },
{ CAP_MMAP, "mm" },
- { CAP_MAPEXEC, "me" },
+ { CAP_CREATE, "cr" },
{ CAP_FEXECVE, "fe" },
{ CAP_FSYNC, "fy" },
{ CAP_FTRUNCATE, "ft" },
- { CAP_SEEK, "se" },
/* VFS methods. */
+ { CAP_FCHDIR, "cd" },
{ CAP_FCHFLAGS, "cf" },
- { CAP_FCHDIR, "cd" },
{ CAP_FCHMOD, "cm" },
{ CAP_FCHOWN, "cn" },
{ CAP_FCNTL, "fc" },
+ { CAP_FLOCK, "fl" },
{ CAP_FPATHCONF, "fp" },
- { CAP_FLOCK, "fl" },
{ CAP_FSCK, "fk" },
{ CAP_FSTAT, "fs" },
{ CAP_FSTATFS, "sf" },
{ CAP_FUTIMES, "fu" },
- { CAP_CREATE, "cr" },
- { CAP_DELETE, "de" },
- { CAP_MKDIR, "md" },
- { CAP_RMDIR, "rm" },
- { CAP_MKFIFO, "mf" },
+ { CAP_LINKAT, "li" },
+ { CAP_MKDIRAT, "md" },
+ { CAP_MKFIFOAT, "mf" },
+ { CAP_MKNODAT, "mn" },
+ { CAP_RENAMEAT, "rn" },
+ { CAP_SYMLINKAT, "sl" },
+ { CAP_UNLINKAT, "un" },
- /* Lookups - used to constraint *at() calls. */
+ /* Lookups - used to constrain *at() calls. */
{ CAP_LOOKUP, "lo" },
/* Extended attributes. */
@@ -201,24 +204,49 @@
{ CAP_SEM_WAIT, "sw" },
/* Event monitoring and posting. */
- { CAP_POLL_EVENT, "po" },
- { CAP_POST_EVENT, "ev" },
+ { CAP_EVENT, "ev" },
+ { CAP_KQUEUE_EVENT, "ke" },
+ { CAP_KQUEUE_CHANGE, "kc" },
/* Strange and powerful rights that should not be given lightly. */
{ CAP_IOCTL, "io" },
{ CAP_TTYHOOK, "ty" },
-#ifdef NOTYET
+ /* Process management via process descriptors. */
{ CAP_PDGETPID, "pg" },
- { CAP_PDWAIT4, "pw" },
+ { CAP_PDWAIT, "pw" },
{ CAP_PDKILL, "pk" },
-#endif
+
+ /*
+ * Rights that allow to use bindat(2) and connectat(2) syscalls on a
+ * directory descriptor.
+ */
+ { CAP_BINDAT, "ba" },
+ { CAP_CONNECTAT, "ca" },
+
+ /* Aliases and defines that combine multiple rights. */
+ { CAP_PREAD, "prd" },
+ { CAP_PWRITE, "pwr" },
+
+ { CAP_MMAP_R, "mmr" },
+ { CAP_MMAP_W, "mmw" },
+ { CAP_MMAP_X, "mmx" },
+ { CAP_MMAP_RW, "mrw" },
+ { CAP_MMAP_RX, "mrx" },
+ { CAP_MMAP_WX, "mwx" },
+ { CAP_MMAP_RWX, "mma" },
+
+ { CAP_RECV, "re" },
+ { CAP_SEND, "sd" },
+
+ { CAP_SOCK_CLIENT, "scl" },
+ { CAP_SOCK_SERVER, "ssr" },
};
static const u_int cap_desc_count = sizeof(cap_desc) /
sizeof(cap_desc[0]);
static u_int
-width_capability(cap_rights_t rights)
+width_capability(cap_rights_t *rightsp)
{
u_int count, i, width;
@@ -225,7 +253,7 @@
count = 0;
width = 0;
for (i = 0; i < cap_desc_count; i++) {
- if (rights & cap_desc[i].cd_right) {
+ if (cap_rights_is_set(rightsp, cap_desc[i].cd_right)) {
width += strlen(cap_desc[i].cd_desc);
if (count)
width++;
@@ -236,20 +264,20 @@
}
static void
-print_capability(cap_rights_t rights, u_int capwidth)
+print_capability(cap_rights_t *rightsp, u_int capwidth)
{
u_int count, i, width;
count = 0;
width = 0;
- for (i = width_capability(rights); i < capwidth; i++) {
- if (rights || i != 0)
+ for (i = width_capability(rightsp); i < capwidth; i++) {
+ if (i != 0)
printf(" ");
else
printf("-");
}
for (i = 0; i < cap_desc_count; i++) {
- if (rights & cap_desc[i].cd_right) {
+ if (cap_rights_is_set(rightsp, cap_desc[i].cd_right)) {
printf("%s%s", count ? "," : "", cap_desc[i].cd_desc);
width += strlen(cap_desc[i].cd_desc);
if (count)
@@ -261,7 +289,7 @@
void
procstat_files(struct procstat *procstat, struct kinfo_proc *kipp)
-{
+{
struct sockstat sock;
struct filestat_list *head;
struct filestat *fst;
@@ -280,7 +308,7 @@
head = procstat_getfiles(procstat, kipp, 0);
if (head != NULL && Cflag) {
STAILQ_FOREACH(fst, head, next) {
- width = width_capability(fst->fs_cap_rights);
+ width = width_capability(&fst->fs_cap_rights);
if (width > capwidth)
capwidth = width;
}
@@ -306,19 +334,19 @@
printf("%5d ", kipp->ki_pid);
printf("%-16s ", kipp->ki_comm);
if (fst->fs_uflags & PS_FST_UFLAG_CTTY)
- printf("ctty ");
+ printf(" ctty ");
else if (fst->fs_uflags & PS_FST_UFLAG_CDIR)
- printf(" cwd ");
+ printf(" cwd ");
else if (fst->fs_uflags & PS_FST_UFLAG_JAIL)
- printf("jail ");
+ printf(" jail ");
else if (fst->fs_uflags & PS_FST_UFLAG_RDIR)
- printf("root ");
+ printf(" root ");
else if (fst->fs_uflags & PS_FST_UFLAG_TEXT)
- printf("text ");
+ printf(" text ");
else if (fst->fs_uflags & PS_FST_UFLAG_TRACE)
printf("trace ");
else
- printf("%4d ", fst->fs_fd);
+ printf("%5d ", fst->fs_fd);
switch (fst->fs_type) {
case PS_FST_TYPE_VNODE:
@@ -423,8 +451,6 @@
printf("%s", fst->fs_fflags & PS_FST_FFLAG_NONBLOCK ? "n" : "-");
printf("%s", fst->fs_fflags & PS_FST_FFLAG_DIRECT ? "d" : "-");
printf("%s", fst->fs_fflags & PS_FST_FFLAG_HASLOCK ? "l" : "-");
- printf("%s ", fst->fs_fflags & PS_FST_FFLAG_CAPABILITY ?
- "c" : "-");
if (!Cflag) {
if (fst->fs_ref_count > -1)
printf("%3d ", fst->fs_ref_count);
@@ -436,7 +462,7 @@
printf("%7c ", '-');
}
if (Cflag) {
- print_capability(fst->fs_cap_rights, capwidth);
+ print_capability(&fst->fs_cap_rights, capwidth);
printf(" ");
}
switch (fst->fs_type) {
Modified: trunk/usr.bin/procstat/procstat_kstack.c
===================================================================
--- trunk/usr.bin/procstat/procstat_kstack.c 2018-07-07 16:42:22 UTC (rev 11449)
+++ trunk/usr.bin/procstat/procstat_kstack.c 2018-07-07 16:43:35 UTC (rev 11450)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2007 Robert N. M. Watson
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/procstat/procstat_kstack.c 310121 2016-12-15 16:52:17Z vangyzen $
*/
#include <sys/param.h>
@@ -134,7 +135,7 @@
unsigned int kip_count, kstk_count;
if (!hflag)
- printf("%5s %6s %-16s %-16s %-29s\n", "PID", "TID", "COMM",
+ printf("%5s %6s %-19s %-19s %-29s\n", "PID", "TID", "COMM",
"TDNAME", "KSTACK");
kkstp = kkstp_free = procstat_getkstack(procstat, kipp, &kstk_count);
@@ -171,10 +172,8 @@
printf("%5d ", kipp->ki_pid);
printf("%6d ", kkstp->kkst_tid);
- printf("%-16s ", kipp->ki_comm);
- printf("%-16s ", (strlen(kipp->ki_tdname) &&
- (strcmp(kipp->ki_comm, kipp->ki_tdname) != 0)) ?
- kipp->ki_tdname : "-");
+ printf("%-19s ", kipp->ki_comm);
+ printf("%-19s ", kinfo_proc_thread_name(kipp));
switch (kkstp->kkst_state) {
case KKST_STATE_RUNNING:
Modified: trunk/usr.bin/procstat/procstat_rlimit.c
===================================================================
--- trunk/usr.bin/procstat/procstat_rlimit.c 2018-07-07 16:42:22 UTC (rev 11449)
+++ trunk/usr.bin/procstat/procstat_rlimit.c 2018-07-07 16:43:35 UTC (rev 11450)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2011 Mikolaj Golub
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/procstat/procstat_rlimit.c 249675 2013-04-20 08:01:00Z trociny $
*/
#include <sys/param.h>
@@ -46,7 +47,7 @@
static struct {
const char *name;
const char *suffix;
-} rlimit_param[14] = {
+} rlimit_param[13] = {
{"cputime", "sec"},
{"filesize", "B "},
{"datasize", "B "},
@@ -60,10 +61,9 @@
{"vmemoryuse", "B "},
{"pseudo-terminals", " "},
{"swapuse", "B "},
- {"kqueues", " "},
};
-#if RLIM_NLIMITS > 14
+#if RLIM_NLIMITS > 13
#error "Resource limits have grown. Add new entries to rlimit_param[]."
#endif
Added: trunk/usr.bin/procstat/procstat_rusage.c
===================================================================
--- trunk/usr.bin/procstat/procstat_rusage.c (rev 0)
+++ trunk/usr.bin/procstat/procstat_rusage.c 2018-07-07 16:43:35 UTC (rev 11450)
@@ -0,0 +1,162 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2012 Hudson River Trading LLC
+ * Written by: John H. Baldwin <jhb at FreeBSD.org>
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/usr.bin/procstat/procstat_rusage.c 283927 2015-06-02 19:20:39Z jhb $");
+
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <sys/user.h>
+
+#include <libprocstat.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <libutil.h>
+
+#include "procstat.h"
+
+static struct {
+ const char *ri_name;
+ bool ri_humanize;
+ int ri_scale;
+} rusage_info[] = {
+ { "maximum RSS", true, 1 },
+ { "integral shared memory", true, 1 },
+ { "integral unshared data", true, 1 },
+ { "integral unshared stack", true, 1 },
+ { "page reclaims", false, 0 },
+ { "page faults", false, 0 },
+ { "swaps", false, 0 },
+ { "block reads", false, 0 },
+ { "block writes", false, 0 },
+ { "messages sent", false, 0 },
+ { "messages received", false, 0 },
+ { "signals received", false, 0 },
+ { "voluntary context switches", false, 0 },
+ { "involuntary context switches", false, 0 }
+};
+
+/* xxx days hh:mm:ss.uuuuuu */
+static const char *
+format_time(struct timeval *tv)
+{
+ static char buffer[32];
+ int days, hours, minutes, seconds, used;
+
+ minutes = tv->tv_sec / 60;
+ seconds = tv->tv_sec % 60;
+ hours = minutes / 60;
+ minutes %= 60;
+ days = hours / 24;
+ hours %= 24;
+ used = 0;
+ if (days == 1)
+ used += snprintf(buffer, sizeof(buffer), "1 day ");
+ else if (days > 0)
+ used += snprintf(buffer, sizeof(buffer), "%u days ", days);
+
+ snprintf(buffer + used, sizeof(buffer) - used, "%02u:%02u:%02u.%06u ",
+ hours, minutes, seconds, (unsigned int)tv->tv_usec);
+ return (buffer);
+}
+
+static const char *
+format_value(long value, bool humanize, int scale)
+{
+ static char buffer[14];
+
+ if (scale != 0)
+ value <<= scale * 10;
+ if (humanize)
+ humanize_number(buffer, sizeof(buffer), value, "B",
+ scale, HN_DECIMAL);
+ else
+ snprintf(buffer, sizeof(buffer), "%ld ", value);
+ return (buffer);
+}
+
+static void
+print_prefix(struct kinfo_proc *kipp)
+{
+
+ printf("%5d ", kipp->ki_pid);
+ if (Hflag)
+ printf("%6d ", kipp->ki_tid);
+ printf("%-16s ", kipp->ki_comm);
+}
+
+static void
+print_rusage(struct kinfo_proc *kipp)
+{
+ long *lp;
+ unsigned int i;
+
+ print_prefix(kipp);
+ printf("%-14s %32s\n", "user time",
+ format_time(&kipp->ki_rusage.ru_utime));
+ print_prefix(kipp);
+ printf("%-14s %32s\n", "system time",
+ format_time(&kipp->ki_rusage.ru_stime));
+ lp = &kipp->ki_rusage.ru_maxrss;
+ for (i = 0; i < nitems(rusage_info); i++) {
+ print_prefix(kipp);
+ printf("%-32s %14s\n", rusage_info[i].ri_name,
+ format_value(*lp, rusage_info[i].ri_humanize,
+ rusage_info[i].ri_scale));
+ lp++;
+ }
+}
+
+void
+procstat_rusage(struct procstat *procstat, struct kinfo_proc *kipp)
+{
+ struct kinfo_proc *kip;
+ unsigned int count, i;
+
+ if (!hflag) {
+ printf("%5s ", "PID");
+ if (Hflag)
+ printf("%6s ", "TID");
+ printf("%-16s %-32s %14s\n", "COMM", "RESOURCE",
+ "VALUE ");
+ }
+
+ if (!Hflag) {
+ print_rusage(kipp);
+ return;
+ }
+
+ kip = procstat_getprocs(procstat, KERN_PROC_PID | KERN_PROC_INC_THREAD,
+ kipp->ki_pid, &count);
+ if (kip == NULL)
+ return;
+ kinfo_proc_sort(kip, count);
+ for (i = 0; i < count; i++)
+ print_rusage(&kip[i]);
+ procstat_freeprocs(procstat, kip);
+}
Property changes on: trunk/usr.bin/procstat/procstat_rusage.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/usr.bin/procstat/procstat_sigs.c
===================================================================
--- trunk/usr.bin/procstat/procstat_sigs.c 2018-07-07 16:42:22 UTC (rev 11449)
+++ trunk/usr.bin/procstat/procstat_sigs.c 2018-07-07 16:43:35 UTC (rev 11450)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2010 Konstantin Belousov
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/procstat/procstat_sigs.c 249668 2013-04-20 07:50:59Z trociny $
*/
#include <sys/param.h>
Modified: trunk/usr.bin/procstat/procstat_threads.c
===================================================================
--- trunk/usr.bin/procstat/procstat_threads.c 2018-07-07 16:42:22 UTC (rev 11449)
+++ trunk/usr.bin/procstat/procstat_threads.c 2018-07-07 16:43:35 UTC (rev 11450)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2007 Robert N. M. Watson
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/procstat/procstat_threads.c 310121 2016-12-15 16:52:17Z vangyzen $
*/
#include <sys/param.h>
@@ -47,7 +48,7 @@
const char *str;
if (!hflag)
- printf("%5s %6s %-16s %-16s %2s %4s %-7s %-9s\n", "PID",
+ printf("%5s %6s %-19s %-19s %2s %4s %-7s %-9s\n", "PID",
"TID", "COMM", "TDNAME", "CPU", "PRI", "STATE", "WCHAN");
kip = procstat_getprocs(procstat, KERN_PROC_PID | KERN_PROC_INC_THREAD,
@@ -59,11 +60,9 @@
kipp = &kip[i];
printf("%5d ", kipp->ki_pid);
printf("%6d ", kipp->ki_tid);
- printf("%-16s ", strlen(kipp->ki_comm) ?
+ printf("%-19s ", strlen(kipp->ki_comm) ?
kipp->ki_comm : "-");
- printf("%-16s ", (strlen(kipp->ki_tdname) &&
- (strcmp(kipp->ki_comm, kipp->ki_tdname) != 0)) ?
- kipp->ki_tdname : "-");
+ printf("%-19s ", kinfo_proc_thread_name(kipp));
if (kipp->ki_oncpu != 255)
printf("%3d ", kipp->ki_oncpu);
else if (kipp->ki_lastcpu != 255)
Modified: trunk/usr.bin/procstat/procstat_vm.c
===================================================================
--- trunk/usr.bin/procstat/procstat_vm.c 2018-07-07 16:42:22 UTC (rev 11449)
+++ trunk/usr.bin/procstat/procstat_vm.c 2018-07-07 16:43:35 UTC (rev 11450)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2007 Robert N. M. Watson
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/procstat/procstat_vm.c 262228 2014-02-19 19:11:14Z jhb $
*/
#include <sys/param.h>
@@ -100,6 +101,9 @@
case KVME_TYPE_SG:
str = "sg";
break;
+ case KVME_TYPE_MGTDEVICE:
+ str = "md";
+ break;
case KVME_TYPE_UNKNOWN:
default:
str = "??";
Added: trunk/usr.bin/procstat/tests/Makefile
===================================================================
--- trunk/usr.bin/procstat/tests/Makefile (rev 0)
+++ trunk/usr.bin/procstat/tests/Makefile 2018-07-07 16:43:35 UTC (rev 11450)
@@ -0,0 +1,10 @@
+# $MidnightBSD$
+# $FreeBSD: stable/10/usr.bin/procstat/tests/Makefile 318325 2017-05-15 22:52:25Z ngie $
+
+ATF_TESTS_SH+= procstat_test
+
+PROGS+= while1
+
+BINDIR= ${TESTSDIR}
+
+.include <bsd.test.mk>
Property changes on: trunk/usr.bin/procstat/tests/Makefile
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/usr.bin/procstat/tests/procstat_test.sh
===================================================================
--- trunk/usr.bin/procstat/tests/procstat_test.sh (rev 0)
+++ trunk/usr.bin/procstat/tests/procstat_test.sh 2018-07-07 16:43:35 UTC (rev 11450)
@@ -0,0 +1,140 @@
+#
+# Copyright (c) 2017 Ngie Cooper <ngie at FreeBSD.org>
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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: stable/10/usr.bin/procstat/tests/procstat_test.sh 318325 2017-05-15 22:52:25Z ngie $
+# $MidnightBSD$
+
+MAX_TRIES=20
+PROG_PID=
+PROG_PATH=$(atf_get_srcdir)/while1
+
+SP='[[:space:]]'
+
+start_program()
+{
+ echo "Starting program in background"
+ PROG_COMM=while1
+ PROG_PATH=$(atf_get_srcdir)/$PROG_COMM
+
+ $PROG_PATH $* &
+ PROG_PID=$!
+ try=0
+ while [ $try -lt $MAX_TRIES ] && ! kill -0 $PROG_PID; do
+ sleep 0.5
+ : $(( try += 1 ))
+ done
+ if [ $try -ge $MAX_TRIES ]; then
+ atf_fail "Polled for program start $MAX_TRIES tries and failed"
+ fi
+}
+
+atf_test_case binary_info
+binary_info_head()
+{
+ atf_set "descr" "Checks -b support"
+}
+binary_info_body()
+{
+ start_program bogus-arg
+
+ line_format="$SP*%s$SP+%s$SP+%s$SP+%s$SP*"
+ header_re=$(printf "$line_format" "PID" "COMM" "OSREL" "PATH")
+ line_re=$(printf "$line_format" $PROG_PID $PROG_COMM "[[:digit:]]+" "$PROG_PATH")
+
+ atf_check -o save:procstat.out procstat -b $PROG_PID
+
+ atf_check -o match:"$header_re" head -n 1 procstat.out
+ atf_check -o match:"$line_re" tail -n 1 procstat.out
+}
+
+atf_test_case command_line_arguments
+command_line_arguments_head()
+{
+ atf_set "descr" "Checks -c support"
+}
+command_line_arguments_body()
+{
+ arguments="my arguments"
+
+ start_program $arguments
+
+ line_format="$SP*%s$SP+%s$SP+%s$SP*"
+ header_re=$(printf "$line_format" "PID" "COMM" "ARGS")
+ line_re=$(printf "$line_format" $PROG_PID "$PROG_COMM" "$PROG_PATH $arguments")
+
+ atf_check -o save:procstat.out procstat -c $PROG_PID
+ atf_check -o match:"$header_re" head -n 1 procstat.out
+ atf_check -o match:"$line_re" tail -n 1 procstat.out
+}
+
+atf_test_case environment
+environment_head()
+{
+ atf_set "descr" "Checks -e support"
+}
+environment_body()
+{
+ var="MY_VARIABLE=foo"
+ eval "export $var"
+
+ start_program my arguments
+
+ line_format="$SP*%s$SP+%s$SP+%s$SP*"
+ header_re=$(printf "$line_format" "PID" "COMM" "ENVIRONMENT")
+ line_re=$(printf "$line_format" $PROG_PID $PROG_COMM ".*$var.*")
+
+ atf_check -o save:procstat.out procstat -e $PROG_PID
+
+ atf_check -o match:"$header_re" head -n 1 procstat.out
+ atf_check -o match:"$line_re" tail -n 1 procstat.out
+}
+
+atf_test_case file_descriptor
+file_descriptor_head()
+{
+ atf_set "descr" "Checks -f support"
+}
+file_descriptor_body()
+{
+ start_program my arguments
+
+ line_format="$SP*%s$SP+%s$SP+%s$SP+%s$SP+%s$SP+%s$SP+%s$SP+%s$SP+%s$SP%s$SP*"
+ header_re=$(printf "$line_format" "PID" "COMM" "FD" "T" "V" "FLAGS" "REF" "OFFSET" "PRO" "NAME")
+ # XXX: write a more sensible feature test
+ line_re=$(printf "$line_format" $PROG_PID $PROG_COMM ".+" ".+" ".+" ".+" ".+" ".+" ".+" ".+")
+
+ atf_check -o save:procstat.out procstat -f $PROG_PID
+
+ atf_check -o match:"$header_re" head -n 1 procstat.out
+ atf_check -o match:"$line_re" awk 'NR > 1' procstat.out
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case binary_info
+ atf_add_test_case command_line_arguments
+ atf_add_test_case environment
+ atf_add_test_case file_descriptor
+}
Property changes on: trunk/usr.bin/procstat/tests/procstat_test.sh
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/usr.bin/procstat/tests/while1.c
===================================================================
--- trunk/usr.bin/procstat/tests/while1.c (rev 0)
+++ trunk/usr.bin/procstat/tests/while1.c 2018-07-07 16:43:35 UTC (rev 11450)
@@ -0,0 +1,41 @@
+/* $MidnightBSD$ */
+/*
+ * Copyright (c) 2017 Ngie Cooper <ngie at FreeBSD.org>
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$FreeBSD: stable/10/usr.bin/procstat/tests/while1.c 318325 2017-05-15 22:52:25Z ngie $");
+
+#include <stdlib.h>
+#include <unistd.h>
+
+int
+main(void)
+{
+
+ for (;;)
+ usleep(100);
+ exit(1);
+}
Property changes on: trunk/usr.bin/procstat/tests/while1.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
More information about the Midnightbsd-cvs
mailing list