aboutsummaryrefslogtreecommitdiff
path: root/bin/ps/print.c
Commit message (Collapse)AuthorAgeFilesLines
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-231-2/+0
| | | | | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/ Similar commit in main: (cherry picked from commit 1d386b48a555)
* src/bin/ps: Fix spelling errorElyes HAOUAS2021-11-191-1/+1
| | | | | | | | Spell interruptible correctly. Pull Request: https://github.com/freebsd/freebsd-src/pull/544 Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr> (cherry picked from commit 3fe686f25a0d0844dc3afd0b3b067ec46abdbc99)
* bin/ps: Avoid function name conflict with libc uname()Alex Richardson2021-08-051-1/+1
| | | | | | | | | | This prevents ps from being built with address sanitizer instrumentation. Reviewed By: trasz MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31048 (cherry picked from commit 2423585b1de50dd2daea8478318e94ff80e0e6ec)
* 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-271-3/+0
| | | | | | | | | | 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-271-0/+16
| | | | | | | | | | | | | | | | | | | | | | | 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-191-9/+9
| | | | | | | | | | | | | | | | | | | | | 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: use %hs instead of %s format specifiersYuri Pankov2020-06-071-3/+3
| | | | | | | | | | | | | 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(1): fix some nitsEitan Adler2018-06-131-3/+1
| | | | | | | | | - 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-131-0/+14
| | | | | | | | | | Inspired by: mwlucas Reviewed by: jamie MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D14683 Notes: svn path=/head/; revision=330872
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-0/+2
| | | | | | | | | | | | | | | | | 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
* Make ps(1) flag processes in capsicum(4) capability mode with "C".Edward Tomasz Napierala2017-09-061-0/+2
| | | | | | | | | 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
* Renumber copyright clause 4Warner Losh2017-02-281-1/+1
| | | | | | | | | | | | 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
* ps(1): Expand variables to match expanded fieldsConrad Meyer2016-06-011-1/+1
| | | | | | | | | | | 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
* Convert to use libxo. Document use of libxo as well.Marcel Moolenaar2015-05-221-13/+14
| | | | | | | | Obtained from: Phil Shafer <phil@juniper.net> Sponsored by: Juniper Networks, Inc. Notes: svn path=/head/; revision=283304
* Use 24h timestamps in the ps(1) STARTED columnMark Felder2015-03-171-7/+2
| | | | | | | | | | | | | | | | | | | | | | | | The previous 12h AM/PM format was perplexing as it didn't follow the locale of the user and was a minor annoyance to FreeBSD users coming from Linux. Additionally, the man page was incorrect about the strftime format. There are three time formats that may be displayed in the STARTED column depending on the age of the process. Below is an example. For a process started at 14:30 on Monday 16 March 2015, the following formats may be used: 14:30 for process < 24h old (24h Timestamp) Mon14 for process > 24h, < 1 week old (Weekday Hour) 16Mar15 for process > 1 week old (Day Month Year) Differential Revision: https://reviews.freebsd.org/D1620 Reviewed by: brd Approved by: trasz Notes: svn path=/head/; revision=280171
* Don't test arrays for being NULL.Edward Tomasz Napierala2013-10-211-7/+1
| | | | | | | MFC after: 1 month Notes: svn path=/head/; revision=256838
* ps: Fix memory leak when showing start/lstart for swapped-out process.Jilles Tjoelker2012-07-151-4/+6
| | | | | | | Spotted by: scan-build (uqs) Notes: svn path=/head/; revision=238488
* Remove unused variables.Ed Schouten2012-01-171-96/+30
| | | | | | | | Simply annotate the function parameters with __unused, instead of adding the ve-variables. This makes the code build with GCC 4.7 and -Werror. Notes: svn path=/head/; revision=230287
* For processes with no controlling terminal, display "-" in the TTY columnEdward Tomasz Napierala2011-10-301-3/+3
| | | | | | | | | instead of "?". Submitted by: arundel Notes: svn path=/head/; revision=226939
* Make ps(1) automatically size its column widths.Edward Tomasz Napierala2011-09-291-354/+231
| | | | Notes: svn path=/head/; revision=225868
* Get rid of major/minor number distinction.Ed Schouten2011-09-281-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | As of FreeBSD 6, devices can only be opened through devfs. These device nodes don't have major and minor numbers anymore. The st_rdev field in struct stat is simply based a copy of st_ino. Simply display device numbers as hexadecimal, using "%#jx". This is allowed by POSIX, since it explicitly states things like the following (example taken from ls(1)): "If the file is a character special or block special file, the size of the file may be replaced with implementation-defined information associated with the device in question." This makes the output of these commands more compact. For example, ls(1) now uses approximately four columns less. While there, simplify the column length calculation from ls(1) by calling snprintf() with a NULL buffer. Don't be afraid; if needed one can still obtain individual major/minor numbers using stat(1). Notes: svn path=/head/; revision=225847
* Rename ki_ocomm to ki_tdname and OCOMMLEN to TDNAMLEN.Bjoern A. Zeeb2011-07-181-7/+7
| | | | | | | | | | | | Provide backward compatibility defines under BURN_BRIDGES. Suggested by: jhb Reviewed by: emaste Sponsored by: Sandvine Incorporated Approved by: re (kib) Notes: svn path=/head/; revision=224199
* Add "gid" and "group" keywords to display the effective group IDEdward Tomasz Napierala2011-06-141-0/+16
| | | | | | | | | | and effective group name. Also, add "egid", "egroup" and "euid" aliases. PR: bin/146331 Submitted by: Jeremie Le Hen <jeremie at le-hen dot org> Notes: svn path=/head/; revision=223086
* Add proper width calculation for time fields (time, cputime and usertime).Edward Tomasz Napierala2011-03-241-1/+43
| | | | | | | This fixes the ugly overflow in "ps aux" output for "[idle]". Notes: svn path=/head/; revision=219972
* Make "LOGIN" and "CLASS" columns width scale properly instead of wasting space.Edward Tomasz Napierala2011-03-241-1/+28
| | | | Notes: svn path=/head/; revision=219967
* Implement the usertime and systime keywords for ps, printing theKonstantin Belousov2011-03-171-18/+51
| | | | | | | | | | corresponding times reported by getrusage(). Submitted by: Dan Nelson <dnelson allantgroup com> MFC after: 1 week Notes: svn path=/head/; revision=219713
* Export login class information via kinfo and make it possible to viewEdward Tomasz Napierala2011-03-051-0/+20
| | | | | | | it using "ps -o class". Notes: svn path=/head/; revision=219307
* Move repeated MAXSLP definition from machine/vmparam.h to sys/vmmeter.h.Konstantin Belousov2011-01-091-0/+1
| | | | | | | | | | Update the outdated comments describing MAXSLP and the process selection algorithm for swap out. Comments wording and reviewed by: alc Notes: svn path=/head/; revision=217192
* o) Add a keyword to displaying elapsed time in integer seconds, "etimes".Juli Mallett2010-03-171-0/+16
| | | | | | | | | o) Give slightly better (i.e. any) documentation of the format of "etime". Reviewed by: jilles Notes: svn path=/head/; revision=205271
* Fix elapsed (etime) field for swapped out processes in ps:Jilles Tjoelker2009-05-241-0/+4
| | | | | | | | | | | | show '-' instead of time since the Epoch. PR: bin/123069 Submitted by: Vladimir Kozbin Approved by: ed (mentor) MFC after: 3 weeks Notes: svn path=/head/; revision=192688
* Add a -d option to ps to display descendant info with the output.Brian Somers2009-05-171-10/+23
| | | | | | | | | This is similar to linux's -H (or -f) switch. MFC after: 3 weeks Notes: svn path=/head/; revision=192239
* [1] When showing threads, the thread name just appears if the commAttilio Rao2009-02-261-2/+24
| | | | | | | | | | | | | | | | | | | | | | label is choosen as last printout (ucomm suffers of this such bug too). That bug is caused by the fact that the fixed size of printout doesn't leave enough space for them to be printed out. Implement ucomm and comm commands with a dynamic size lenght for buffers. [2] On AMD64 architecture pointers don't have enough chars space to be shown (8 chars while they need 16). Fix them by providing a variadic space so that it fits well on both 64 and 32 bits architectures. [3] Check a return value of malloc() that wasn't checked before. PR: bin/128841, bin/128842 Reviewed by: jhb, emaste Sponsored by: Sandvine Incorporated Notes: svn path=/head/; revision=189078
* Fix whitespace.Ed Maste2008-11-131-3/+2
| | | | Notes: svn path=/head/; revision=184925
* Introduce a way to make pure kernal threads.Julian Elischer2007-10-261-4/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | kthread_add() takes the same parameters as the old kthread_create() plus a pointer to a process structure, and adds a kernel thread to that process. kproc_kthread_add() takes the parameters for kthread_add, plus a process name and a pointer to a pointer to a process instead of just a pointer, and if the proc * is NULL, it creates the process to the specifications required, before adding the thread to it. All other old kthread_xxx() calls return, but act on (struct thread *) instead of (struct proc *). One reason to change the name is so that any old kernel modules that are lying around and expect kthread_create() to make a process will not just accidentally link. fix top to show kernel threads by their thread name in -SH mode add a tdnam formatting option to ps to show thread names. make all idle threads actual kthreads and put them into their own idled process. make all interrupt threads kthreads and put them in an interd process (mainly for aesthetic and accounting reasons) rename proc 0 to be 'kernel' and it's swapper thread is now 'swapper' man page fixes to follow. Notes: svn path=/head/; revision=173004
* - Move all of the PS_ flags into either p_flag or td_flags.Jeff Roberson2007-09-171-5/+4
| | | | | | | | | | | | | | | | | - p_sflag was mostly protected by PROC_LOCK rather than the PROC_SLOCK or previously the sched_lock. These bugs have existed for some time. - Allow swapout to try each thread in a process individually and then swapin the whole process if any of these fail. This allows us to move most scheduler related swap flags into td_flags. - Keep ki_sflag for backwards compat but change all in source tools to use the new and more correct location of P_INMEM. Reported by: pho Reviewed by: attilio, kib Approved by: re (kensmith) Notes: svn path=/head/; revision=172207
* For pts, print the pts number, instead of the full name. As it was, we endedOlivier Houchard2006-02-211-0/+2
| | | | | | | | | up always printing "pts". Submitted by: Michal Mertl <mime at traveller dot cz> Notes: svn path=/head/; revision=155876
* Use warn() instead of perror().Tim J. Robbins2004-07-201-2/+2
| | | | Notes: svn path=/head/; revision=132433
* Change the "rtprio" format so it prints an informative string forGarance A Drosehn2004-06-271-0/+3
| | | | | | | | | the PRI_ITHD case (instead of just printing the digit '1'). Submitted by: Cyrille Lefevre Notes: svn path=/head/; revision=131215
* Change "struct varent" to use the standard queue(8) macros, instead ofGarance A Drosehn2004-06-231-14/+12
| | | | | | | | | using it's own version of the same basic algorithm. Submitted by: part by Cyrille Lefevre, part of it done by me Notes: svn path=/head/; revision=130999
* Avoid padding the value of "ucomm" when it is the last column in the line.Garance A Drosehn2004-06-231-1/+4
| | | | | | | Submitted by: Cyrille Lefevre Notes: svn path=/head/; revision=130975
* Make sure the value of "upr" (scheduling priority on return from system call)Garance A Drosehn2004-06-231-1/+13
| | | | | | | | | is scaled in the same way that "pri" (scheduling priority) is scaled. Submitted by: Cyrille Lefevre Notes: svn path=/head/; revision=130974
* Have `ps' return the cputimes for zombies, with the assumption thatGarance A Drosehn2004-06-211-1/+1
| | | | | | | | | | kvm_getprocs() will provide useful information if it can, or *it* will provide a zero value if it can not find something appropriate. Submitted by: bde Notes: svn path=/head/; revision=130856
* Add the `-O emul' format option, which prints the name of the system-callGarance A Drosehn2004-06-201-0/+9
| | | | | | | | | | | emulation environment the process is in. "emul" as a keyword is picked up from OpenBSD. PR: bin/65803 Submitted by: Cyrille Lefevre Notes: svn path=/head/; revision=130830
* From SUSv3:Garance A Drosehn2004-06-201-1/+1
| | | | | | | | | | | | | | Any [standard output] field need not be meaningful in all implementations. In such a case a hyphen ('-') should be output in place of the field value So have the `-O label' option print out the string " -" if the process has no label. Approved by: Silence from rwatson and green (when asked in March...) Notes: svn path=/head/; revision=130828
* Remove clause 3 from the UCB licenses.Mark Murray2004-04-061-4/+0
| | | | | | | OK'ed by: imp, core Notes: svn path=/head/; revision=127958
* Fix `-o rtprio' so it prints the correct value.Garance A Drosehn2004-03-281-2/+2
| | | | | | | | | PR: bin/59417 Submitted by: Jan Willem Knopper This fix by: bde (in the audit-trail of the PR) Notes: svn path=/head/; revision=127512
* Implement the nwchan keyword that has been in the man page, but wasHartmut Brandt2003-08-131-0/+13
| | | | | | | | not implemented. This is just handy if you want to ddb the address some process is waiting on. Notes: svn path=/head/; revision=118857