svn commit: r204879 - head/usr.bin/procstat

Konstantin Belousov kib at FreeBSD.org
Mon Mar 8 20:44:23 UTC 2010


Author: kib
Date: Mon Mar  8 20:44:22 2010
New Revision: 204879
URL: http://svn.freebsd.org/changeset/base/204879

Log:
  Teach procstat(1) to display some information about signal disposition
  and pending/blocked status for signals.
  
  Reviewed by:	rwatson
  MFC after:	2 weeks

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	Mon Mar  8 19:58:00 2010	(r204878)
+++ head/usr.bin/procstat/Makefile	Mon Mar  8 20:44:22 2010	(r204879)
@@ -9,6 +9,7 @@ SRCS=	procstat.c		\
 	procstat_cred.c		\
 	procstat_files.c	\
 	procstat_kstack.c	\
+	procstat_sigs.c		\
 	procstat_threads.c	\
 	procstat_vm.c
 

Modified: head/usr.bin/procstat/procstat.1
==============================================================================
--- head/usr.bin/procstat/procstat.1	Mon Mar  8 19:58:00 2010	(r204878)
+++ head/usr.bin/procstat/procstat.1	Mon Mar  8 20:44:22 2010	(r204879)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 20, 2008
+.Dd March 7, 2010
 .Dt PROCSTAT 1
 .Os
 .Sh NAME
@@ -34,8 +34,9 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl h
+.Op Fl n
 .Op Fl w Ar interval
-.Op Fl b | c | f | k | s | t | v
+.Op Fl b | c | f | i | j | k | s | t | v
 .Op Fl a | Ar pid ...
 .Sh DESCRIPTION
 The
@@ -56,6 +57,10 @@ Display binary information for the proce
 Display command line arguments for the process.
 .It Fl f
 Display file descriptor information for the process.
+.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.
 .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.
@@ -204,6 +209,58 @@ direct I/O
 .It l
 lock held
 .El
+.Ss Signal Disposition Information
+Display signal pending and disposition for a process:
+.Pp
+.Bl -tag -width ident -compact
+.It PID
+process ID
+.It COMM
+command
+.It SIG
+signal name
+.It FLAGS
+process signal disposition details, three symbols
+.Bl -tag -width X -compact
+.It P
+if signal is pending in the global process queue, - otherwise
+.It I
+if signal delivery disposition is SIGIGN, - otherwise
+.It C
+if signal delivery is to catch it, - otherwise
+.El
+.El
+.Pp
+If
+.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:
+.Pp
+.Bl -tag -width ident -compact
+.It PID
+process ID
+.It COMM
+command
+.It TID
+thread ID
+.It SIG
+signal name
+.It FLAGS
+thread signal delivery status, two symbols
+.Bl -tag -width X -compact
+.It P
+if signal is pending for the thread, - otherwise
+.It B
+if signal is blocked in the thread signal mask, - if not blocked
+.El
+.El
+.Pp
+The
+.Fl n
+switch has the same effect as for the
+.Fl i
+switch, the signals 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.

Modified: head/usr.bin/procstat/procstat.c
==============================================================================
--- head/usr.bin/procstat/procstat.c	Mon Mar  8 19:58:00 2010	(r204878)
+++ head/usr.bin/procstat/procstat.c	Mon Mar  8 20:44:22 2010	(r204879)
@@ -38,15 +38,15 @@
 
 #include "procstat.h"
 
-static int aflag, bflag, cflag, fflag, kflag, sflag, tflag, vflag;
-int	hflag;
+static int aflag, bflag, cflag, fflag, iflag, jflag, kflag, sflag, tflag, vflag;
+int	hflag, nflag;
 
 static void
 usage(void)
 {
 
-	fprintf(stderr, "usage: procstat [-h] [-w interval] [-b | -c | -f | "
-	    "-k | -s | -t | -v]\n");
+	fprintf(stderr, "usage: procstat [-h] [-n] [-w interval] [-b | -c | -f | "
+	    "-i | -j | -k | -s | -t | -v]\n");
 	fprintf(stderr, "                [-a | pid ...]\n");
 	exit(EX_USAGE);
 }
@@ -61,6 +61,10 @@ procstat(pid_t pid, struct kinfo_proc *k
 		procstat_args(pid, kipp);
 	else if (fflag)
 		procstat_files(pid, kipp);
+	else if (iflag)
+		procstat_sigs(pid, kipp);
+	else if (jflag)
+		procstat_threads_sigs(pid, kipp);
 	else if (kflag)
 		procstat_kstack(pid, kipp, kflag);
 	else if (sflag)
@@ -109,7 +113,7 @@ main(int argc, char *argv[])
 	char *dummy;
 
 	interval = 0;
-	while ((ch = getopt(argc, argv, "abcfkhstvw:")) != -1) {
+	while ((ch = getopt(argc, argv, "abcfijknhstvw:")) != -1) {
 		switch (ch) {
 		case 'a':
 			aflag++;
@@ -127,10 +131,22 @@ main(int argc, char *argv[])
 			fflag++;
 			break;
 
+		case 'i':
+			iflag++;
+			break;
+
+		case 'j':
+			jflag++;
+			break;
+
 		case 'k':
 			kflag++;
 			break;
 
+		case 'n':
+			nflag++;
+			break;
+
 		case 'h':
 			hflag++;
 			break;

Modified: head/usr.bin/procstat/procstat.h
==============================================================================
--- head/usr.bin/procstat/procstat.h	Mon Mar  8 19:58:00 2010	(r204878)
+++ head/usr.bin/procstat/procstat.h	Mon Mar  8 20:44:22 2010	(r204879)
@@ -29,7 +29,7 @@
 #ifndef PROCSTAT_H
 #define	PROCSTAT_H
 
-extern int	hflag;
+extern int	hflag, nflag;
 
 struct kinfo_proc;
 void	kinfo_proc_sort(struct kinfo_proc *kipp, int count);
@@ -40,7 +40,9 @@ void	procstat_bin(pid_t pid, struct kinf
 void	procstat_cred(pid_t pid, struct kinfo_proc *kipp);
 void	procstat_files(pid_t pid, struct kinfo_proc *kipp);
 void	procstat_kstack(pid_t pid, struct kinfo_proc *kipp, int kflag);
+void	procstat_sigs(pid_t pid, struct kinfo_proc *kipp);
 void	procstat_threads(pid_t pid, struct kinfo_proc *kipp);
+void	procstat_threads_sigs(pid_t pid, struct kinfo_proc *kipp);
 void	procstat_vm(pid_t pid, struct kinfo_proc *kipp);
 
 #endif /* !PROCSTAT_H */


More information about the svn-src-head mailing list