aboutsummaryrefslogtreecommitdiff
path: root/bin/ps
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Correct the history of where ps first appeared.Warren Block2016-08-121-1/+2
| | | | | | | | | PR: 211741 Submitted by: Sevan Janiyan <venture37@geeklan.co.uk> MFC after: 1 week Notes: svn path=/head/; revision=304007
* When a debugger attaches to the process, SIGSTOP is sent to theKonstantin Belousov2016-07-281-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | target. Due to a way issignal() selects the next signal to deliver and report, if the simultaneous or already pending another signal exists, that signal might be reported by the next waitpid(2) call. This causes minor annoyance for debuggers, which must be prepared to take any signal as the first event, then filter SIGSTOP later. More importantly, for tools like gcore(1), which attach and then detach without processing events, SIGSTOP might leak to be delivered after PT_DETACH. This results in the process being unintentionally stopped after detach, which is fatal for automatic tools. The solution is to force SIGSTOP to be the first signal reported after the attach. Attach code is modified to set P2_PTRACE_FSTP to indicate that the attaching ritual was not yet finished, and issignal() prefers SIGSTOP in that condition. Also, the thread which handles P2_PTRACE_FSTP is made to guarantee to own p_xthread during the first waitpid(2). All that ensures that SIGSTOP is consumed first. Additionally, if P2_PTRACE_FSTP is still set on detach, which means that waitpid(2) was not called at all, SIGSTOP is removed from the queue, ensuring that the process is resumed on detach. In issignal(), when acting on STOPing signals, remove the signal from queue before suspending. Otherwise parallel attach could result in ptracestop() acting on that STOP as if it was the STOP signal from the attach. Then SIGSTOP from attach leaks again. As a minor refactoring, some bits of the common attach code is moved to new helper proc_set_traced(). Reported by: markj Reviewed by: jhb, markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D7256 Notes: svn path=/head/; revision=303423
* Addm missed required call to xo_finish() when only header is printed.Konstantin Belousov2016-07-231-0/+1
| | | | | | | | | Reported by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=303213
* ps(1): Expand variables to match expanded fieldsConrad Meyer2016-06-012-2/+2
| | | | | | | | | | | ki_flag and ki_tdflag have been 'long', not 'int', since 2000 and 2005, respectively. Submitted by: Shawn Wills <swills at isilon dot com> Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=301160
* Fix CID 1011370 (Resource leak) in ps.Don Lewis2016-05-252-8/+11
| | | | | | | | | | | | | | | | There is no need to to call strdup() on the value returned by fmt(). The latter calls fmt_argv() which always returns a dynamically allocated string, and calling strdup() on that leaks the memory allocated by fmt_argv(). Wave some const magic on ki_args and ki_env to make the direct assignment happy. This requires a tweak to the asprintf() case to avoid a const vs. non-const mismatch. Reported by: Coverity CID: 1011370 MFC after: 1 week Notes: svn path=/head/; revision=300648
* Use NULL instead of 0 for pointers.Marcelo Araujo2016-04-191-1/+1
| | | | | | | | | kvm_open(3) will return NULL when it cannot access kernel virtual memory. MFC after: 2 weeks. Notes: svn path=/head/; revision=298233
* MFHGlen Barber2016-02-101-1/+1
|\ | | | | | | | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=295458
| * Rename P_KTHREAD struct proc p_flag to P_KPROC.Konstantin Belousov2016-02-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | I left as is an apparent bug in ntoskrnl_var.h:AT_PASSIVE_LEVEL() definition. Suggested by: jhb Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=295435
* | Explicitly add unmarked bin/ binaries to the runtime package.Glen Barber2016-02-091-0/+1
|/ | | | | | | | | | | Note: tcsh(1) has a MK_TCSH=no test, so this should be a separate package, which requires pre-install/post-install scripts, to be added later. Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=295439
* Fix spelling, as recommended by igor tool.Craig Rodrigues2015-12-011-1/+1
| | | | Notes: svn path=/head/; revision=291608
* Add more text to explain --libxo flag.Craig Rodrigues2015-12-011-1/+8
| | | | Notes: svn path=/head/; revision=291607
* Update dependencies after r291406 added libelf to libkvm.Bryan Drewery2015-12-011-0/+1
| | | | | | | | | | | Unfortunately filemon/meta mode tracks all indirect dependencies here since ld(1) is reading libelf when linking in libkvm. Churn would be reduced if this was able to be limited to direct dependencies. Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=291558
* Make libxo depend on libutil because it uses humanize_number after r287111Enji Cooper2015-10-181-1/+1
| | | | | | | | | | | Remove overlinking in lib/libxo/tests, sbin/savecore, and usr.bin/{iscsictl,wc,xo} PR: 203673 Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=289490
* Update META_MODE dependencies.Bryan Drewery2015-09-171-0/+1
| | | | Notes: svn path=/head/; revision=287905
* Upgrade libxo to 0.4.5.Marcel Moolenaar2015-08-241-1/+1
| | | | | | | | | | Local changes incorporated by 0.4.5: r284340 Local changes retained: r276260, r282117 Obtained from: https://github.com/Juniper/libxo Notes: svn path=/head/; revision=287111
* mdoc: minor Xr fixesJoel Dahl2015-07-141-2/+2
| | | | Notes: svn path=/head/; revision=285556
* Add META_MODE support.Simon J. Gerraty2015-06-131-0/+22
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Off by default, build behaves normally. WITH_META_MODE we get auto objdir creation, the ability to start build from anywhere in the tree. Still need to add real targets under targets/ to build packages. Differential Revision: D2796 Reviewed by: brooks imp Notes: svn path=/head/; revision=284345
| * dirdeps.mk now sets DEP_RELDIRSimon J. Gerraty2015-06-081-2/+0
| | | | | | | | Notes: svn path=/projects/bmake/; revision=284172
| * Merge sync of headSimon J. Gerraty2015-05-277-177/+260
| |\ | | | | | | | | | Notes: svn path=/projects/bmake/; revision=283595