Commit graph

473 commits

Author SHA1 Message Date
Alexander Ziaee 1a720cbec5 man filesystems: fix xrefs after move to section 4
Reviewed by: des, imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1077
2024-05-16 10:25:29 -06:00
Jamie Landeg-Jones 3f0b80bc15 ps: handle incorrect -D values
I just noticed a slight issue with the '-D' option. Basically,
I accidentally typed something along the lines of:

ps -Dboth-p303

I.E. missing out the "space". Instead of giving an error, it behaved as
if I'd just typed "ps".

Looking at bin/ps/ps.c, where the -D option is parsed, it doesn't
error-out if there is no valid match.

This commit fixes the bug.
2024-05-06 19:13:35 +02:00
Warner Losh e043f37205 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
2023-11-26 22:23:59 -07:00
Warner Losh 0b8224d1cc Remove copyright strings ifdef'd out
We've ifdef'd out the copyright strings for some time now. Go ahead and
remove the ifdefs. Plus whatever other detritis was left over from other
recent removals. These copyright strings are present in the comments and
are largely from CSRG's attempt at adding their copyright to every
binary file (which modern interpretations of the license doesn't
require).

Sponsored by:		Netflix
2023-11-26 22:23:58 -07:00
Warner Losh 90aea514c6 bin: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by:		Netflix
2023-11-26 22:23:28 -07:00
Brooks Davis 1818f3fda9 ps: s/kern.max_pid/kern.pid_max/ in a comment
Sponsored by:	DARPA
2023-11-21 22:46:01 +00:00
Benedict Reuschling ba44650a0b ps.1: update regarding -D option and -p x/d interaction
The -p option does not imply -x, it is merely a different mode that ps
uses. Remove that statement from the -p option, effectively rolling back
d6ae056e9d.

pstef@ introduced the -D option in 5c0a1c15ff
which also turns ps into a similar mode. List the -D option along with
the others in the first sentence of the second paragraph of the
DESCRIPTION section for completeness and correctness sake.

Pointed out by:		pstef@
Differential Revision:	https://reviews.freebsd.org/D42552
2023-11-11 19:49:24 +00:00
Benedict Reuschling d6ae056e9d Extend description of -p to include interactions with -d and implying -x
PR:	268052
Event:	Oslo Hackathon
Differential Revision: https://reviews.freebsd.org/D40595
2023-10-06 14:29:21 +00:00
Piotr Pawel Stefaniak 5c0a1c15ff ps: add a new option -D to reimplement tree traversal
It takes a non-optional parameter string, one of "up", "down", or "both"
that can request tree traversal in the chosen directions. This adds PIDs
from the paths to the selection of PIDs and can be used together with -d
to draw a subset of the process tree.

Differential Revision:	https://reviews.freebsd.org/D41231
2023-08-24 18:35:56 +02:00
Piotr Pawel Stefaniak f06e32e9b9 Revert "ps: extend the non-standard option -d (tree view) to work with -p"
This reverts commit ca8c0d5e81.

By commiting ca8c0d5e81 I was hoping that the existing option -d
could just be extended to work with -p to implement a feature that was
and I think is still needed, that is to show all descendant processes
of a given process id or a set of process ids.

After a complaint from -current which may represent a wider
dissatisfaction with this change in the program's behavior, I think it
will be better to revert ca8c0d5e81 and reintroduce this feature
using a separate option -D.
2023-08-24 18:35:50 +02:00
Warner Losh b2c76c41be Remove $FreeBSD$: one-line nroff pattern
Remove /^\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:15 -06:00
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh 42b388439b Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:23 -06:00
Mateusz Piotrowski 820ac12679 ps: Add libxo to usage message
MFC after:	1 week
Sponsored by:	Klara Inc.
2023-04-25 17:23:07 +02:00
Mateusz Piotrowski 3f46bf40a1 ps: Fix synopsis
In the -L mode, the -L flag is not optional.

MFC after:	3 days
Sponsored by:	Klara Inc.
2023-04-25 17:23:07 +02:00
Simon J. Gerraty d9a4274795 Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
Alfonso 3322d1c0e2 ps(1): Use calloc instead of malloc and memset.
Pull Request:	https://github.com/freebsd/freebsd-src/pull/546
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-03-11 10:36:00 +01:00
Elyes HAOUAS 3fe686f25a src/bin/ps: Fix spelling error
Spell interruptible correctly.

Pull Request: https://github.com/freebsd/freebsd-src/pull/544
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
2021-10-02 10:39:37 -06:00
Math Ieu bf27a2253f ps: fix ps -aa
Passing the -a flag multiple times made ps show no processes.

Differential Revision:	https://reviews.freebsd.org/D27215
2021-09-24 21:19:52 +02:00
Alex Richardson 2423585b1d bin/ps: Avoid function name conflict with libc uname()
This prevents ps from being built with address sanitizer instrumentation.

Reviewed By:	trasz
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D31048
2021-07-19 15:04:09 +01:00
Mark Johnston c7f893a42b ps(1): Fix formatting of the "command" field for kernel threads.
When -H is specified, for kernel threads the command is formatted as
"<proc name>/<td name>" and truncated to MAXCOMLEN.  But each of the
proc name and td name may be up to MAXCOMLEN bytes in length.

Also handle the ki_moretdname field to ensure that the full thread name
gets printed.  This is already handled correctly when formatting for
"-o tdname".

Reported by:	freqlabs
Reviewed by:	freqlabs
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D25840
2020-07-28 15:26:19 +00:00
Kirk McKusick 4a022f0e06 Update to D25266, bin/ps: Make the rtprio option actually show
realtime priorities

The current `ps -axO rtprio' show threads running at interrupt
priority such as the [intr] thread as '1:48' and threads running
at kernel priority such as [pagedaemon] as normal:4294967260.

This change shows [intr] as intr:48 and [pagedaemon] as kernel:4.

Reviewed by:    kib
MFC after:	1 week (together with -r362369)
Differential Revision: https://reviews.freebsd.org/D25660
2020-07-14 18:57:31 +00:00
Piotr Pawel Stefaniak ac4b8a1ce4 ps(1): don't try to handle non-SMP systems
As reported by kib, sysctl machdep.smp_active doesn't exist and on UP we
return CPU 0 for all threads anyway.

Reported by:	kib
2020-06-27 20:01:56 +00:00
Piotr Pawel Stefaniak 4f47f5111f ps(1): reuse keyword "cpu" to show CPU number
This flag will now show the processor number on which a process is running.

This change was inspired by PR129965. Initially I didn't think that the
patch attached to it was correct -- it sacrificed ki_estcpu use in "cpu"
for ki_lastcpu and I thought that the old functionality should be kept and
the new (cpu#) one added to it. But I've since discovered that ki_estcpu is
sched_4bsd-specific. What's worse, it represents the same thing as
ki_pctcpu, except ki_pctcpu is universal -- so "%cpu" has been using it
successfully. Therefore, I've decided to replace information based on
ki_estcpu with information based on ki_oncpu/ki_lastcpu.

Key parts of the code and manual changes were borrowed from top(1).

PR:		129965
Reported by:	Nikola Knežević
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D25377
2020-06-27 19:09:33 +00:00
Lorenzo Salvadore 50301bb0a1 bin/ps: Make the rtprio option actually show realtime priorities
Fix the rtprio option that for some reason was progessively becoming an
option showing the priority class of threads. In particular:

- use the constants defined in sys/sys/rtprio.h instead of those defined in
  sys/sys/priority.h: this helps making clearer that the code actually is
  about realtime priorities and not standard scheduler priorities;
- remove the PRI_ITHD case that has nothing to do with realtime priorities;
- convert the priority levels to realtime priority levels using the same
  formulas used for pri_to_rtp function in sys/kern/kern_resource.c.
- remove outdated note "101 = not a realtime process" in the man page and
  replace it with a more useful reference to man 1 rtprio.

Approved by:	src (mckusick), manpages (bcr), gerald (mentor)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D25266
2020-06-19 09:27:58 +00:00
Yuri Pankov 26161fcfca ps: remove xo_no_setlocale() call
Apparently libxo was fixed to do the right thing on FreeBSD,
and calling xo_no_setlocale() is no longer needed.

Reported by:	phil
2020-06-09 07:07:29 +00:00
Yuri Pankov aa8ab14697 ps: use %hs instead of %s format specifiers
Use %hs (locale-based encoding) instead of %s (UTF-8) format for
strings that are expected to be in current locale encoding (date/time,
process names/argument list).

PR:		241491
Reviewed by:	phil
Differential Revision:	https://reviews.freebsd.org/D22160
2020-06-07 08:21:19 +00:00
Piotr Pawel Stefaniak ca8c0d5e81 ps: extend the non-standard option -d (tree view) to work with -p
Initially it seemed that there were multiple possible ways to do it.

Processing option -p could conditionally add selected processes and
their descendants to the list for further work, but it is not guaranteed
to know whether the -d option has been used or not, and it also doesn't
have access to the process list just yet.

There is also descendant_sort() which has access to all possibly needed
information, but serves the purely post-processing purpose of sorting
output.

Then there is the loop that uses invocation information and full process
list to create a list of processes for final display. It seems the most
natural place to implement this, but indeterminate state of the process
list and volatility of the final list that is being created obstruct
adding an elegant search for all elements of process descendancy trees.

So I opted for adding another loop, just before the one I mentioned
above. For all selected processes it conditionally adds direct
descendants to the end of this list of selected processes.

Possible usage:
* ps -auxd -p $$
* ps -auxd -p 1
* while x=$(pgrep svnlite); do clear; ps auxd -p $x; sleep 2; done
* ps -auxd -p `pgrep make`

Reviewed by:	kevans, kaktus (earlier version)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D24380
2020-05-07 16:56:18 +00:00
Mateusz Piotrowski f11e51a920 ps(1): Pet mandoc and igor
- Use Xr to reference other manual pages.
- Reference execve(2) instead of exec(2) as exec(2) does not exist.
- Remove the deprecated "Tn" macro.
- Improve the formatting of the etime description.

Reviewed by:	bcr
Approved by:	krion (mentor, implicit), mat (mentor, implicit)
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D17780
2018-10-31 17:47:08 +00:00
Mateusz Piotrowski c97c08de8a ps(1): Add a standard exit status section
Reviewed by:	bcr, eadler
Approved by:	krion (mentor)
MFC after:      3 days
Differential Revision:	https://reviews.freebsd.org/D17146
2018-10-31 16:10:04 +00:00
Eitan Adler c6a5ff7153 ps(1): fix some nits
- fracmem and mempages are double. ki_rssize should be too
- remove default case that is fully covered by all existing cases
- mark usage as dead
2018-06-13 00:45:35 +00:00
John Baldwin 2f5a9b7661 Add a "jail" keyword to list the name of a jail rather than its ID.
Inspired by:	mwlucas
Reviewed by:	jamie
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D14683
2018-03-13 18:30:26 +00:00
Mike Karels 30417f2cd4 Change ps(1) output width to unlimited if not interactive
Apply patch submitted with PR 217159 to make ps use unlimited
width when not associated with a terminal (i.e., none of stdout, stdin,
or stderr is a tty). Update comments and man page correspondingly.
This change was requested to work around lack of -ww in scripts from
third-party packages, including Hadoop, and adds a small measure of
Linux compatibility. Hopefully few if any non-interactive scripts
depend on the old default of 79.

PR:		217159
Submitted by:	n.deepak at gmail.com
Reviewed by:	vangyzen jhb
Differential Revision:	https://reviews.freebsd.org/D14614
2018-03-10 00:10:47 +00:00
Mike Karels b93bb974cc Revert r314685 in ps
Revert r314685, and add a comment describing the original
behavior and the intent.

Reviewed by:	dab@ vangyzen@ jhb@
Differential Revision:	https://reviews.freebsd.org/D14530
2018-02-28 00:17:08 +00:00
John Baldwin faf5dd873e Remove some KSE references from ps(1).
- Simplify the description of -H to assume 1:1 threading.
- Drop 'process' from description of 'lwp' field and the corresponding
  XO field name.
- Do add an expansion of LWP in the description of 'lwp' and 'nlwps'.
- Add 'tid' as an alias for the 'lwp' field.

Reviewed by:	imp, kib (older version)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D14021
2018-01-23 22:48:06 +00:00
Edward Tomasz Napierala 536062099a Add "vmaddr" ps(1) keyword.
Obtained from:	CheriBSD
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2017-12-01 11:32:05 +00:00
Pedro F. Giffuni 8a16b7a18f General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

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.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:49:47 +00:00
Bryan Drewery ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Edward Tomasz Napierala 4363782bc3 Undocument "tdnam" (leaving it as an alias), and rename the column
to TDNAME.

Suggested by:	bde
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2017-10-09 13:53:41 +00:00
Edward Tomasz Napierala 42ee5c3342 Fix long name (used by libxo) for the "tdnam" ps(1) keyword.
Reported by:	pluknet
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2017-10-09 13:48:10 +00:00
Edward Tomasz Napierala a8373a7c1f Document "tdnam" keyword to ps(1), and add "tdname" alias.
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2017-10-09 10:24:06 +00:00
Edward Tomasz Napierala d7026b9671 Fix kvm_getprocs(3) error reporting in ps(1).
Previously it just didn't work at all - kvm_getprocs(3) doesn't update
the &nentries when it returns NULL.  The end result was that ps(1) showed
garbage data instead of reporting kinfo_proc size mismatch.

Reviewed by:	cem
Obtained from:	CheriBSD
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D12414
2017-10-06 15:09:28 +00:00
Edward Tomasz Napierala cde94a423f Hint that the "-o emul" option for ps(1) shows the ABI.
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2017-09-07 10:56:50 +00:00
Edward Tomasz Napierala 6f47d67bfe Make ps(1) flag processes in capsicum(4) capability mode with "C".
Obtained from:	CheriBSD
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2017-09-06 16:34:42 +00:00
Edward Tomasz Napierala e4d52dfd1b Reflect realtime and idle priorities in ps(1) state flags, same like
we do for the usual nice values.  It could be argued that they should
use another set of indicators, since the underlying mechanism is
different, but they match the description in the manual page, and so
I think it's ok to not overcomplicate things.

PR:		81757
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2017-09-06 16:18:06 +00:00
Edward Tomasz Napierala 4162d13907 Use the "tree" word in ps(1) -d option description, to make it easier
to find.

MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2017-07-22 10:38:44 +00:00
Conrad Meyer ef1d40da16 ps(1): Fix -w + UNLIMITED handling
A follow-up fix for r314685.

Because the -w flag is parsed after ps(1) infers termwidth from COLUMNS and
stdout, and UNLIMITED happens to be the zero value, the single -w flag in
combination with a non-terminal stdout or COLUMNS=0 could result in output
truncated at 131 characters.  (Despite the output being unlimited without
-w.)

Obviously, adding more -w shouldn't truncate output lines.

The committed patch is from bdrewery@, and I've reviewed and tested it.

Submitted by:	bdrewery@
Reported by:	bdrewery@
Sponsored by:	Dell EMC Isilon
2017-03-07 04:51:35 +00:00
Conrad Meyer 9c4241c3d7 ps(1): Only detect terminal width if stdout is a tty
If stdout isn't a tty, use unlimited width output rather than truncating to
79 characters.  This is helpful for shell scripts or e.g., 'ps | grep foo'.

This hardcoded width has some history: In The Beginning of History[0], the
width of ps was hardcoded as 80 bytes.  In 1985, Bloom@ added detection
using TIOCGWINSZ on stdin.[1]  In 1986, Kirk merged a change to check
stdout's window size instead.  In 1990, the fallback checks to stderr and
stdin's TIOCGWINSZ were added by Marc@, with the commit message "new
version."[2]

OS X Darwin has a very similar modification to ps(1), which simply sets
UNLIMITED for all non-tty outputs.[3]  I've chosen to respect COLUMNS
instead of behaving identically to Darwin here, but I don't feel strongly
about that.  We could match OS X for parity if that is desired.

[0]: https://svnweb.freebsd.org/csrg/bin/ps/ps.c?annotate=1065
[1]: https://svnweb.freebsd.org/csrg/bin/ps/ps.c?r1=18105&r2=18106
[2]:
https://svnweb.freebsd.org/csrg/bin/ps/ps.c?r1=40675&r2=40674&pathrev=40675
[3]:
https://opensource.apple.com/source/adv_cmds/adv_cmds-168/ps/ps.c.auto.html

PR:		217159
Reported by:	Deepak Nagaraj <n.deepak at gmail.com>
2017-03-04 22:38:10 +00:00
Warner Losh fbbd9655e5 Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2017-02-28 23:42:47 +00:00