aboutsummaryrefslogtreecommitdiff
path: root/bin/ps
Commit message (Collapse)AuthorAgeFilesLines
* bin: Automated cleanup of cdefs and other formattingWarner Losh2023-11-274-15/+0
| | | | | | | | | | | | | | | | 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
* Remove copyright strings ifdef'd outWarner Losh2023-11-271-10/+0
| | | | | | | | | | | 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
* bin: Remove ancient SCCS tags.Warner Losh2023-11-279-22/+0
| | | | | | | | 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
* ps: s/kern.max_pid/kern.pid_max/ in a commentBrooks Davis2023-11-211-1/+1
| | | | Sponsored by: DARPA
* ps.1: update regarding -D option and -p x/d interactionBenedict Reuschling2023-11-111-7/+2
| | | | | | | | | | | | | | 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 d6ae056e9dc96c2db45982ac358ba9ed716a9202. pstef@ introduced the -D option in 5c0a1c15ff8cb66128f4826ace8ba91e0a31486d 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
* Extend description of -p to include interactions with -d and implying -xBenedict Reuschling2023-10-061-1/+6
| | | | | | PR: 268052 Event: Oslo Hackathon Differential Revision: https://reviews.freebsd.org/D40595
* ps: add a new option -D to reimplement tree traversalPiotr Pawel Stefaniak2023-08-242-4/+61
| | | | | | | | | 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
* Revert "ps: extend the non-standard option -d (tree view) to work with -p"Piotr Pawel Stefaniak2023-08-241-9/+1
| | | | | | | | | | | | | | This reverts commit ca8c0d5e811048ad67d0955642c5b486e9c0f3d2. By commiting ca8c0d5e8110 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 ca8c0d5e8110 and reintroduce this feature using a separate option -D.
* Remove $FreeBSD$: one-line nroff patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\.\\"\s*\$FreeBSD\$$\n/
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-162-2/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-165-10/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* Remove $FreeBSD$: one-line .h patternWarner Losh2023-08-162-2/+0
| | | | Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
* ps: Add libxo to usage messageMateusz Piotrowski2023-04-251-3/+3
| | | | | MFC after: 1 week Sponsored by: Klara Inc.
* ps: Fix synopsisMateusz Piotrowski2023-04-252-3/+3
| | | | | | | In the -L mode, the -L flag is not optional. MFC after: 3 days Sponsored by: Klara Inc.
* Update/fix Makefile.depend for userlandSimon J. Gerraty2023-04-191-4/+1
|
* ps(1): Use calloc instead of malloc and memset.Alfonso2022-03-111-2/+1
| | | | | | Pull Request: https://github.com/freebsd/freebsd-src/pull/546 MFC after: 1 week Sponsored by: NVIDIA Networking
* src/bin/ps: Fix spelling errorElyes HAOUAS2021-10-021-1/+1
| | | | | | | Spell interruptible correctly. Pull Request: https://github.com/freebsd/freebsd-src/pull/544 Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
* ps: fix `ps -aa`Math Ieu2021-09-241-6/+1
| | | | | | Passing the -a flag multiple times made ps show no processes. Differential Revision: https://reviews.freebsd.org/D27215
* bin/ps: Avoid function name conflict with libc uname()Alex Richardson2021-07-193-3/+3
| | | | | | | | This prevents ps from being built with address sanitizer instrumentation. Reviewed By: trasz MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31048
* ps(1): Fix formatting of the "command" field for kernel threads.Mark Johnston2020-07-281-4/+7
| | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=363649
* Update to D25266, bin/ps: Make the rtprio option actually showKirk McKusick2020-07-141-1/+8
| | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=363192
* ps(1): don't try to handle non-SMP systemsPiotr Pawel Stefaniak2020-06-273-19/+1
| | | | | | | | | | 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 Notes: svn path=/head/; revision=362707
* ps(1): reuse keyword "cpu" to show CPU numberPiotr Pawel Stefaniak2020-06-275-5/+37
| | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=362705
* bin/ps: Make the rtprio option actually show realtime prioritiesLorenzo Salvadore2020-06-192-10/+11
| | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=362369
* ps: remove xo_no_setlocale() callYuri Pankov2020-06-091-1/+0
| | | | | | | | | | Apparently libxo was fixed to do the right thing on FreeBSD, and calling xo_no_setlocale() is no longer needed. Reported by: phil Notes: svn path=/head/; revision=361962
* ps: use %hs instead of %s format specifiersYuri Pankov2020-06-073-5/+6
| | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=361887
* ps: extend the non-standard option -d (tree view) to work with -pPiotr Pawel Stefaniak2020-05-071-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=360786
* ps(1): Pet mandoc and igorMateusz Piotrowski2018-10-311-7/+8
| | | | | | | | | | | | | | | - 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 Notes: svn path=/head/; revision=339962
* ps(1): Add a standard exit status sectionMateusz Piotrowski2018-10-311-1/+3
| | | | | | | | | | Reviewed by: bcr, eadler Approved by: krion (mentor) MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D17146 Notes: svn path=/head/; revision=339957
* ps(1): fix some nitsEitan Adler2018-06-132-5/+3
| | | | | | | | | - 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 Notes: svn path=/head/; revision=335023
* Add a "jail" keyword to list the name of a jail rather than its ID.John Baldwin2018-03-134-1/+19
| | | | | | | | | | Inspired by: mwlucas Reviewed by: jamie MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D14683 Notes: svn path=/head/; revision=330872
* Change ps(1) output width to unlimited if not interactiveMike Karels2018-03-102-4/+19
| | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=330712
* Revert r314685 in psMike Karels2018-02-281-2/+9
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=330091
* Remove some KSE references from ps(1).John Baldwin2018-01-232-10/+7
| | | | | | | | | | | | | | | - 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 Notes: svn path=/head/; revision=328306
* Add "vmaddr" ps(1) keyword.Edward Tomasz Napierala2017-12-012-1/+5
| | | | | | | | | Obtained from: CheriBSD MFC after: 2 weeks Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=326430
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-207-0/+14
| | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=326025
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2017-10-311-1/+0
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325188
* Undocument "tdnam" (leaving it as an alias), and rename the columnEdward Tomasz Napierala2017-10-092-5/+4
| | | | | | | | | | | to TDNAME. Suggested by: bde MFC after: 2 weeks Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=324430
* Fix long name (used by libxo) for the "tdnam" ps(1) keyword.Edward Tomasz Napierala2017-10-091-1/+1
| | | | | | | | | Reported by: pluknet MFC after: 2 weeks Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=324429
* Document "tdnam" keyword to ps(1), and add "tdname" alias.Edward Tomasz Napierala2017-10-092-1/+5
| | | | | | | | MFC after: 2 weeks Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=324427
* Fix kvm_getprocs(3) error reporting in ps(1).Edward Tomasz Napierala2017-10-061-1/+5
| | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=324367
* Hint that the "-o emul" option for ps(1) shows the ABI.Edward Tomasz Napierala2017-09-071-2/+2
| | | | | | | | MFC after: 2 weeks Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=323263
* Make ps(1) flag processes in capsicum(4) capability mode with "C".Edward Tomasz Napierala2017-09-062-1/+7
| | | | | | | | | Obtained from: CheriBSD MFC after: 2 weeks Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=323228
* Reflect realtime and idle priorities in ps(1) state flags, same likeEdward Tomasz Napierala2017-09-061-2/+2
| | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=323225
* Use the "tree" word in ps(1) -d option description, to make it easierEdward Tomasz Napierala2017-07-221-2/+2
| | | | | | | | | | to find. MFC after: 2 weeks Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=321368
* ps(1): Fix -w + UNLIMITED handlingConrad Meyer2017-03-071-1/+1
| | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=314832
* ps(1): Only detect terminal width if stdout is a ttyConrad Meyer2017-03-041-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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> Notes: svn path=/head/; revision=314685
* Renumber copyright clause 4Warner Losh2017-02-288-8/+8
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=314436
* Export the whole thread name in kinfo_procEric van Gyzen2016-12-071-6/+10
| | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=309676
* Remove description of P_FOLLOWFORK as this flag was removed.John Baldwin2016-08-121-2/+1
| | | | Notes: svn path=/head/; revision=304009