From owner-svn-src-head@FreeBSD.ORG Mon Mar 8 20:44:23 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 11A791065673; Mon, 8 Mar 2010 20:44:23 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E9EEA8FC0C; Mon, 8 Mar 2010 20:44:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o28KiMgc002561; Mon, 8 Mar 2010 20:44:22 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o28KiMcb002556; Mon, 8 Mar 2010 20:44:22 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201003082044.o28KiMcb002556@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 8 Mar 2010 20:44:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204879 - head/usr.bin/procstat X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Mar 2010 20:44:23 -0000 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 */