History log of /freebsd-current/usr.bin/procstat/procstat.c
Revision Date Author Comments
# 5e3934b1 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

usr.bin: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# a5229a25 02-Apr-2022 Konstantin Belousov <kib@FreeBSD.org>

Implement procstat(1) advlocks command

to display list of the advisory file locks in the system.

Example output
$ procstat advlock
RW TYPE PID SYSID FSID RDEV INO START LEN PATH
RO FCNTL 5836 0 0x878700ff02 0xffffffffffffffff 57 0 0 /tmp/2
RW FLOCK -1 0 0x878700ff02 0xffffffffffffffff 13 0 0 /tmp/1

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D34834


# e79866dd 07-Apr-2022 Konstantin Belousov <kib@FreeBSD.org>

procstat(1): add ability to specify subcommands not requiring pid lists

Add PS_MODE_NO_KINFO_PROC cmd modifier that indicates that neither
process list should be queried from the kernel, nor list of pids or `-a`
switch provided on the command line to filter the output.

This is intended for use by commands that query information not
neccessary attributed to specific process.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D34834


# 8b1f5965 17-Mar-2022 Piotr Pawel Stefaniak <pstef@FreeBSD.org>

procstat: remove set but not used variable

In an earlier version of D26310, strcmp was strncmp.


# 34d7dd15 28-Sep-2020 Konstantin Belousov <kib@FreeBSD.org>

procstat: Fix regression after 365880.

Basically it reverts one chunk that reversed the parsing logic, making
legacy variants of invocation, like `procstat -a -f', non-operational.

Reported and tested by: Dewayne Geraghty <dewayne@heuristicsystems.com.au>
Sponsored by: The FreeBSD Foundation
MFC after: 3 days


# b65eb2f8 27-Sep-2020 Konstantin Belousov <kib@FreeBSD.org>

Consistently use __FBSDID("FreeBSD") for ids in usr.bin/procstat.

Submitted by: Juraj Lutter <juraj@lutter.sk>
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D26568


# 085e0494 17-Sep-2020 Konstantin Belousov <kib@FreeBSD.org>

Add pargs, penv, pwdx commands and aliases to procstat(1).

Intent is to mimic Solaris commands with the same names.

Submitted by: Juraj Lutter <juraj@lutter.sk>
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D26310


# 24d57fa8 08-Feb-2020 Konstantin Belousov <kib@FreeBSD.org>

Add procstat(1) sigfastblock command to show process sigfastblock word address.

Tested by: pho
Disscussed with: cem, emaste, jilles
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D12773


# 1de7b4b8 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

various: general adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.


# 6effb213 16-Nov-2017 Andriy Gapon <avg@FreeBSD.org>

procstat: fix a crash with -k -a options

The traditional / legacy usage should still be supported.
This fixes a regression in r324619 that introduced a nicer, verb based
interface.

Reviewed by: brooks
X-MFC with: r324619


# 2a243b95 14-Oct-2017 Brooks Davis <brooks@FreeBSD.org>

Switch procstat from subcommand flags to verbs

- Use an enumerated value instead of separate flags for commands
- Look for a verb if no command flag is set
- Lookup the "xocontainer" value based on the command
- Document the new command verbs in the man-page

Submitted by: kdrakehp@zoho.com
Differential Revision: https://reviews.freebsd.org/D10916


# 8490e4c2 19-Jul-2017 Enji Cooper <ngie@FreeBSD.org>

procstat(8): clarify program usage

- Visualize mutually exclusive options and their corresponding
arguments.
- Try to make the subtleties that are expressed in the code, and
potentially in the manpages, more apparent.


# fbf87d40 26-May-2017 Brooks Davis <brooks@FreeBSD.org>

Add missing usage and getopt(3) options

- Add the missing option 'n' to the getopt(3) string
- Add the missing options 'libxo' and 'N' to the usage message
- Add the missing options 'M' and 'N' to the man-page

Submitted by: Keegan Drake H.P. <kdrakehp@zoho.com>
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D10915


# 86be94fc 30-Mar-2017 Tycho Nightingale <tychon@FreeBSD.org>

Add support for capturing 'struct ptrace_lwpinfo' for signals
resulting in a process dumping core in the corefile.

Also extend procstat to view select members of 'struct ptrace_lwpinfo'
from the contents of the note.

Sponsored by: Dell EMC Isilon


# 3d32d4a7 07-Dec-2016 Eric van Gyzen <vangyzen@FreeBSD.org>

Export the whole thread name in kinfo_proc

kinfo_proc::ki_tdname is three characters shorter than
thread::td_name. Add a ki_moretdname field for these three
extra characters. Add the new field to kinfo_proc32, as well.
Update all in-tree consumers to read the new field and assemble
the full name, except for lldb's HostThreadFreeBSD.cpp, which
I will handle separately. Bump __FreeBSD_version.

Reviewed by: kib
MFC after: 1 week
Relnotes: yes
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D8722


# 474b62b8 05-Sep-2015 Allan Jude <allanjude@FreeBSD.org>

Introduce libxo to procstat(1)

Reviewed by: rodrigc, bapt
Approved by: marcel (mentor)
Relnotes: yes
Sponsored by: ScaleEngine Inc.
Differential Revision: https://reviews.freebsd.org/D2446


# a506f1dd 11-Mar-2015 Scott Long <scottl@FreeBSD.org>

Fix a typo and update the date in the man page.

Submitted by: emax
Obtained from: Netflix, Inc.
MFC after: 3 days


# cee9136c 10-Mar-2015 Scott Long <scottl@FreeBSD.org>

Implement basic cpuset reporting in procstat via the -S flag.

Obtained from: Netflix, Inc.
MFC after: 3 days


# dc0aa067 16-May-2014 John Baldwin <jhb@FreeBSD.org>

- Add support for dumping current resource usage for processes via a new -r
flag to procstat.
- Add an -H flag to request information about threads rather than processes
when dumping statistics. Currently it is only used for -r to display
resource usage for individual threads instead of the entire process.

Reviewed by: kib (older version without -H)
MFC after: 1 month


# 948baa40 20-Apr-2013 Mikolaj Golub <trociny@FreeBSD.org>

Make use of newly added libprocstat(3) ability to extract procstat
info from a process core file.

So now one can run procstat(1) on a process core e.g. to get a list of
files opened by a process when it crashed:

root@lisa:/ # procstat -f /root/vi.core
PID COMM FD T V FLAGS REF OFFSET PRO NAME
658 vi text v r r-------- - - - /usr/bin/vi
658 vi ctty v c rw------- - - - /dev/pts/0
658 vi cwd v d r-------- - - - /root
658 vi root v d r-------- - - - /
658 vi 0 v c rw------- 11 3208 - /dev/pts/0
658 vi 1 v c rw------- 11 3208 - /dev/pts/0
658 vi 2 v c rw------- 11 3208 - /dev/pts/0
658 vi 3 v r r----n-l- 1 0 - /tmp/vi.0AYKz3Lps7
658 vi 4 v r rw------- 1 0 - /var/tmp/vi.recover/vi.GaGYsz
658 vi 5 v r rw------- 1 0 - -

PR: kern/173723
Suggested by: jhb
MFC after: 1 month


# d86fa0c7 20-Apr-2013 Mikolaj Golub <trociny@FreeBSD.org>

Use procstat_getkstack(3) for retrieving process kernel stacks
instead of direct sysctl calls.

MFC after: 1 month


# 61e1b7c6 20-Apr-2013 Mikolaj Golub <trociny@FreeBSD.org>

Use libprocstat(3) to retrieve ELF auxiliary vector.

MFC after: 1 month


# 729e63c3 20-Apr-2013 Mikolaj Golub <trociny@FreeBSD.org>

Use libprocstat(3) to retrieve process command line arguments and
environment variables.

MFC after: 1 month


# 66e2f999 20-Apr-2013 Mikolaj Golub <trociny@FreeBSD.org>

Use libprocstat(3) when retrieving binary information for a process.

MFC after: 1 month


# 21b4f75a 20-Apr-2013 Mikolaj Golub <trociny@FreeBSD.org>

Use procstat_getrlimit(3) for retrieving rlimit information instead of
direct sysctl calls.

MFC after: 1 month


# e40d6078 20-Apr-2013 Mikolaj Golub <trociny@FreeBSD.org>

Use procstat_getgroups(3) for retrieving groups information instead of
direct sysctl.

MFC after: 1 month


# eee7107c 20-Apr-2013 Mikolaj Golub <trociny@FreeBSD.org>

Use more generic procstat_getvmmap(3) for retrieving VM layout of a process.

MFC after: 1 month


# efade150 20-Apr-2013 Mikolaj Golub <trociny@FreeBSD.org>

Use procstat_getprocs(3) for retrieving thread information instead of
direct sysctl calls.

MFC after: 1 month


# c0eb2f03 12-Jan-2013 Mateusz Guzik <mjg@FreeBSD.org>

procstat: only one mode flag can be specified, but required check for 'i'
and 'j' modes was missing. Fix that.

MFC after: 3 days


# 598585e8 24-Nov-2011 Mikolaj Golub <trociny@FreeBSD.org>

usr.bin/procstat

Add -l flag to display resource limits.

PR: bin/161257
Reviewed by: kib
MFC after: 2 weeks


# e99272c7 22-Nov-2011 Mikolaj Golub <trociny@FreeBSD.org>

Add new options, -e and -x, to display process environment variables
and ELF auxiliary vectors.

MFC after: 2 weeks


# d57486e2 13-Aug-2011 Robert Watson <rwatson@FreeBSD.org>

Updates to libprocstat(3) and procstat(1) to allow monitoring Capsicum
capability mode and capabilities.

Right now no attempt is made to unwrap capabilities when operating on
a crashdump, so further refinement is required.

Approved by: re (bz)
Sponsored by: Google Inc


# 0daf62d9 12-May-2011 Stanislav Sedov <stas@FreeBSD.org>

- Commit work from libprocstat project. These patches add support for runtime
file and processes information retrieval from the running kernel via sysctl
in the form of new library, libprocstat. The library also supports KVM backend
for analyzing memory crash dumps. Both procstat(1) and fstat(1) utilities have
been modified to take advantage of the library (as the bonus point the fstat(1)
utility no longer need superuser privileges to operate), and the procstat(1)
utility is now able to display information from memory dumps as well.

The newly introduced fuser(1) utility also uses this library and able to operate
via sysctl and kvm backends.

The library is by no means complete (e.g. KVM backend is missing vnode name
resolution routines, and there're no manpages for the library itself) so I
plan to improve it further. I'm commiting it so it will get wider exposure
and review.

We won't be able to MFC this work as it relies on changes in HEAD, which
was introduced some time ago, that break kernel ABI. OTOH we may be able
to merge the library with KVM backend if we really need it there.

Discussed with: rwatson


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 1b90b87f 22-Mar-2010 Konstantin Belousov <kib@FreeBSD.org>

MFC r204879:
Teach procstat(1) to display some information about signal disposition
and pending/blocked status for signals.

MFC r204880:
Add file forgotten in r204879.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# 55f65cd9 08-Mar-2010 Konstantin Belousov <kib@FreeBSD.org>

Teach procstat(1) to display some information about signal disposition
and pending/blocked status for signals.

Reviewed by: rwatson
MFC after: 2 weeks


# e1f323f3 29-Dec-2008 Robert Watson <rwatson@FreeBSD.org>

Include param.h instead of types.h before user.h so that the nested
include of param.h can be removed from audit.h.

MFC after: 3 weeks


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 97ce0ae6 08-Feb-2008 David Malone <dwmalone@FreeBSD.org>

WARNS fixes: mainly constness and avoid comparing signed with
unsigned by making array indicies unsigned. Also note one or two
unused parameters.


# 3d91be41 02-Dec-2007 Robert Watson <rwatson@FreeBSD.org>

Add procstat(1), a process inspection utility. This provides both some
of the missing functionality from procfs(4) and new functionality for
monitoring and debugging specific processes. procstat(1) operates in
the following modes:

-b Display binary information for the process.
-c Display command line arguments for the process.
-f Display file descriptor information for the process.
-k Display the stacks of kernel threads in the process.
-s Display security credential information for the process.
-t Display thread information for the process.
-v Display virtual memory mappings for the process.

Further revision and modes are expected.

Testing, ideas, etc: cognet, sam, Skip Ford <skip at menantico dot com>
Wesley Shields <wxs at atarininja dot org>