History log of /freebsd-10.1-release/bin/ps/keyword.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 272461 02-Oct-2014 gjb

Copy stable/10@r272459 to releng/10.1 as part of
the 10.1-RELEASE process.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 267904 26-Jun-2014 pluknet

MFC r267196:

Add support for inspecting process flags set in p_flag2.


# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


# 254943 26-Aug-2013 will

Add the ability to display the default FIB number for a process to the
ps(1) utility, e.g. "ps -O fib".

bin/ps/keyword.c:
Add the "fib" keyword and default its column name to "FIB".

bin/ps/ps.1:
Add "fib" as a supported keyword.

sys/compat/freebsd32/freebsd32.h:
sys/kern/kern_proc.c:
sys/sys/user.h:
Add the default fib number for a process (p->p_fibnum)
to the user land accessible process data of struct kinfo_proc.

Submitted by: Oliver Fromme <olli@fromme.com>, gibbs


# 240645 18-Sep-2012 zont

- Add 'dsiz' and 'ssiz' keywords to show data and stack size respectively.

Approved by: kib (mentor)
MFC after: 1 week


# 235851 23-May-2012 kib

Add 'cow' keyword to show per-process cow count.

Submitted by: Andrey Zonov <andrey zonov org>
MFC after: 1 week


# 225868 29-Sep-2011 trasz

Make ps(1) automatically size its column widths.


# 224199 18-Jul-2011 bz

Rename ki_ocomm to ki_tdname and OCOMMLEN to TDNAMLEN.
Provide backward compatibility defines under BURN_BRIDGES.

Suggested by: jhb
Reviewed by: emaste
Sponsored by: Sandvine Incorporated
Approved by: re (kib)


# 223086 14-Jun-2011 trasz

Add "gid" and "group" keywords to display the effective group ID
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>


# 220574 12-Apr-2011 trasz

Get rid of DSIZ; instead just call the sizing function if provided.


# 219972 24-Mar-2011 trasz

Add proper width calculation for time fields (time, cputime and usertime).
This fixes the ugly overflow in "ps aux" output for "[idle]".


# 219967 24-Mar-2011 trasz

Make "LOGIN" and "CLASS" columns width scale properly instead of wasting space.


# 219713 17-Mar-2011 kib

Implement the usertime and systime keywords for ps, printing the
corresponding times reported by getrusage().

Submitted by: Dan Nelson <dnelson allantgroup com>
MFC after: 1 week


# 219307 05-Mar-2011 trasz

Export login class information via kinfo and make it possible to view
it using "ps -o class".


# 213536 07-Oct-2010 emaste

Make a thread's address available via the kern proc sysctl, just like the
process address.

Add "tdaddr" keyword to ps(1) to display this thread address.

Distilled from Sandvine's patch set by Mark Johnston.


# 210448 24-Jul-2010 trasz

Fix alignment for the 'flags' label, and make more room for 'tdev'.

MFC after: 1 month


# 205271 17-Mar-2010 jmallett

o) Add a keyword to displaying elapsed time in integer seconds, "etimes".
o) Give slightly better (i.e. any) documentation of the format of "etime".

Reviewed by: jilles


# 199351 17-Nov-2009 netchild

Fix small resource leak (memory).

Reviewed by: gad
MFC after: 1 week


# 198848 03-Nov-2009 delphij

Increase width for %CPU, RSS and VSZ columns for now. Modern systems
tend to have larger memory, larger process, and more CPU.


# 189078 26-Feb-2009 attilio

[1] When showing threads, the thread name just appears if the comm
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


# 173100 28-Oct-2007 julian

fix sorting of 'tdnam' keyword in keyword list.


# 173004 26-Oct-2007 julian

Introduce a way to make pure kernal threads.
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.


# 157559 06-Apr-2006 gad

Re-correct commit 1.73, but this time in a way that does not cause
all column-headers to print in lowercase by default. I was in too
much of a rush in committing 1.75, and didn't notice that the case
had changed. This time I did considerably more testing, and used
'diff' instead of just quickly eyeballing the results...

Apologies. I expect this means the dunce cap is mine for awhile.
If this doesn't work, I'll just drop back to 1.72 and hide under
my desk for awhile.


# 157538 05-Apr-2006 gad

Fix a problem introduced by change 1.73, which causes a seg-fault if
the user specifies a keyword which is an alias to some other keyword.
E.g.: stat (for state) or pcpu (for %cpu)..

Submitted by: Kostik Belousov
MFC plans: "soon"


# 156424 08-Mar-2006 gad

Collapse strncpy/strncat/strncat into a single snprintf, as suggested
by pjd.

MFC after: 3 weeks


# 156423 08-Mar-2006 gad

Fix the case where the user specifies an alternate heading for some
output-format keyword, and the keyword they picked is an alias to
some other keyword. E.g.: ps -o stat=Zustand $$
('stat' is defined as an alias for 'state')

PR: bin/57833
MFC after: 3 weeks


# 143872 20-Mar-2005 pjd

Add and document the 'jid' keyword for the '-o' option.

Reviewed by: gad
MFC after: 3 days


# 141401 06-Feb-2005 csjp

Since it is not un-common for a process's resident set size (rss)
to exceed 10 megabytes in size (especially in X), bump the max
column width from 4 bytes to 5. This will make the ps auxw output
uniform again when a process's rss exceeds 10 megs.

It should be noted that when 5 digits becomes to small, other
solutions should be explored such as displaying them in megabytes
or having ps automatically re-size column widths.

Discussed with: gad
MFC after: 1 week


# 130999 23-Jun-2004 gad

Change "struct varent" to use the standard queue(8) macros, instead of
using it's own version of the same basic algorithm.

Submitted by: part by Cyrille Lefevre, part of it done by me


# 130974 23-Jun-2004 gad

Make sure the value of "upr" (scheduling priority on return from system call)
is scaled in the same way that "pri" (scheduling priority) is scaled.

Submitted by: Cyrille Lefevre


# 130830 20-Jun-2004 gad

Add the `-O emul' format option, which prints the name of the system-call
emulation environment the process is in. "emul" as a keyword is picked
up from OpenBSD.

PR: bin/65803
Submitted by: Cyrille Lefevre


# 130827 20-Jun-2004 gad

Add new output-format keywords of LWP and NLWP, which show the thread-id
and number-of-threads tied to a process. Result can be seen by typing,
e.g.: ps -HO lwp,nlwp
These new options are not documented yet. More options will be coming,
and I will update the man page after I get farther along.

PR: bin/65803 (though adjusted to fit our present source)
Submitted by: Cyrille Lefevre


# 127958 06-Apr-2004 markm

Remove clause 3 from the UCB licenses.

OK'ed by: imp, core


# 125612 08-Feb-2004 jmallett

MFp4 @46705:

Support "uprocp" exactly like "paddr" with the former having been
documented in the manual but not implemented.

PR: 42484


# 118857 13-Aug-2003 harti

Implement the nwchan keyword that has been in the man page, but was
not implemented. This is just handy if you want to ddb the address
some process is waiting on.


# 113395 12-Apr-2003 tjr

Display residency and sleep times (re and sl fields) larger than 127 as 127.
This is what the manual page says ps should do, and what OpenBSD and NetBSD do.
Based on a patch from Ken Stailey.

PR: 27433, 46232


# 110411 05-Feb-2003 sobomax

Fix slight disorder that broke sorting. Put in bold warning about the
fact that in this case order matters.

Submitted by: Peter Edwards <pmedwards@eircom.net>


# 110391 05-Feb-2003 charnier

Display elapsed time (-o etime) using [[dd-]hh:]mm:ss, which according to
Solaris man page is the POSIX way.

Reviewed by: jmallett


# 109504 18-Jan-2003 jmallett

Per-variable\ entry headers, to allow the 'ps -otime -otime=FOO' or similar
case to do the right thing and affect exactly one column. This is consistent
with GNU ps(1) in BSD mode, and POLA.


# 109502 18-Jan-2003 jmallett

When inserting a non-user-specified (e.g. not via -o or -O) format, don't dupe
one that is already there. This is consistent with GNU ps(1)'s BSD mode, and
POLA.

Reported by: Andy Farkas <andyf@speednet.com.au>
Tested by: Andy Farkas <andyf@speednet.com.au>


# 105831 23-Oct-2002 rwatson

Use the MAC interface to list process MAC labels rather than using
the LOMAC-specific interface (which is being deprecated). The
revised LOMAC using the MAC framework will export levels listable
using this mechanism.

Approved by: re
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories


# 104388 02-Oct-2002 jhb

Catch up to SMTX -> SLOCK changes.


# 104026 26-Sep-2002 jmallett

List valid keywords, ala kill(1), rather than the csh builtin kill, which
tells people to type kill -l, when no valid ones are specified.

Sponsored by: Bright Path Solutions
MFC after: 4 days


# 104025 26-Sep-2002 jmallett

Ala kill(1), tell people to type 'ps -L' for a list of format keywords.

Sponsored by: Rachel Hestilow <rachel@jerkcity.com>
MFC after: 2 weeks


# 103497 17-Sep-2002 jmallett

Rename new PLONG type to PGTOK as the conversion is more important than the
size (which is mostly undefined anyway).

Submitted by: bde


# 103438 17-Sep-2002 jmallett

Conglomerate printing of ps_pgtok'd data into a PLONG type. I couldn't think
of a better name, except PINT, but I decided to go with assuming LONG to
be safe, rather than assuming INT.


# 103422 16-Sep-2002 jmallett

Perform keyword.c:1.27 properly, implement -orss in the New World Order of
ps(1) formatting, using pgtok() to get the value in K, rather than printing
it in pages. This is consistent with behaviour before keyword.c:1.26 (et al)
which exists in STABLE today, and which uses the same metric as VSZ.

Submitted by: bde


# 103421 16-Sep-2002 jmallett

Remove some NOTINUSE stuff. Good housekeeping.


# 99580 08-Jul-2002 robert

- Use (MAXLOGNAME - 1) where UT_NAMESIZE was used to be able to
(-)remove the inclusions of <utmp.h>.


# 99110 30-Jun-2002 obrien

Consistently use FBSDID


# 98050 08-Jun-2002 jmallett

Allow whitespace to act as a delimiter in the keywords list given to the -o,
again, but also allow it in the user-specified header, too. This is far more
backwards compatible and SUSv3-happy than allowing only comma to seperate the
keywords list.

Submitted by: tjr


# 97965 06-Jun-2002 jmallett

Implement a SUSv3-ignorant but "time"-similar format for "etime", elapsed
run time (NOT cpu time). cputime() and elapsed() both need to honour SUSv3
now.


# 97961 06-Jun-2002 jmallett

Support the SUSv3 `rgroup' format.

Clean up some local style bogons.


# 97958 06-Jun-2002 jmallett

SUSv3 conform on the "comm" and "args" formats, and make correct the "command"
format, since it's BSDlike, and "comm" is actually different.


# 97944 06-Jun-2002 jmallett

As per behaviour on SVR4 systems, to allow any desirable type of header in the
override, seperate by comma (',') only, rather than any type of whitespace
(the literal space character (' ') had already been removed from this list).

This allows things like:
miamivice# ps -opid='Process
> Identifier'
Process
Identifier
1350
1445
1450

To work.


# 97877 05-Jun-2002 jmallett

Widen the scope of fmt.c::1.19 and consistently use errx(3) if malloc(3) [or
realloc(3)] happens to fail, everywhere in ps(1).

Discussed with: bde, charnier (a while ago)

fmt_argv() can no longer return NULL, so don't bother checking.

Submitted by: bde


# 97850 05-Jun-2002 jmallett

Support the 'comm' keyword, which is equivalent to our 'command', but
specified by SUSv3.


# 97849 05-Jun-2002 jmallett

A space cannot be a header string seperator it appears given the SUSv3
description of ps(1), which uses them. I question whether newline and tab
can be either, but I'm not touching them. Yet.


# 97848 04-Jun-2002 jmallett

To comply with SUSv3, duplicate the variable contents for each given format,
so that multiple -ovar=header lines do not overwrite eachother.

This means that ps -ouser=USERNAME -ouser=WHO would now possibly print:
USERNAME WHO
juli juli

Whereas before it would be:
WHO WHO
juli juli


# 97842 04-Jun-2002 jmallett

Duplicate the pointer to the string containing the header so it does not get
frobbed when/if the pointer it is actually a part of gets freed.


# 91028 21-Feb-2002 dillon

Revert wchan functionality. Add 'mwchan' to supply new duel mutex/msleep
functionality and make it the default.

With additional improvements by: Mark Peek <mp@FreeBSD.org>


# 90143 03-Feb-2002 markm

WARNS=4 fixes (incomplete, so set NO_WERROR), and lots of extra
cleanup courtesy of automatic checking (lint).


# 90110 02-Feb-2002 imp

o __P has been reoved
o Old-style K&R declarations have been converted to new C89 style
o register has been removed
o prototype for main() has been removed (gcc3 makes it an error)
o int main(int argc, char *argv[]) is the preferred main definition.
o Attempt to not break style(9) conformance for declarations more than
they already are.


# 88904 05-Jan-2002 peter

Put the "mtxname" keyword in alphabetical order (t comes after s) so
that the keyword is recognized.


# 86922 26-Nov-2001 green

Add LOMAC options (the "Z" flag in both cases) to display extra information
in ls(1) and ps(1).

Sponsored by: DARPA, NAI Labs


# 82268 24-Aug-2001 peter

On today's kernels masking with ~KERNBASE is turning out to be less
than useful. It still hits at least 8 digits. Adjust for reality.

This is still not satisfactory for the alpha if you add "-O paddr".


# 76245 03-May-2001 markm

Depollute headers now that the VM headers DTRT.


# 76168 01-May-2001 markm

Compensate for header dethreading.


# 75435 11-Apr-2001 brian

Introduce -osid and -otsid

Submitted by: dd


# 72489 14-Feb-2001 jlemon

Do not coredump if no options are supplied. (ps -o,)

Submitted by: rgrimes
Obtained from: NetBSD


# 72377 11-Feb-2001 jake

Catch up to new priority interface.


# 70079 16-Dec-2000 mckusick

Restore the rss (-u) keyword that got deleted in my somewhat over-zealous
cleanup effort.

Submitted by: Mark Peek <mark@whistle.com>


# 69896 12-Dec-2000 mckusick

Change the proc information returned from the kernel so that it
no longer contains kernel specific data structures, but rather
only scalar values and structures that are already part of the
kernel/user interface, specifically rusage and rtprio. It no
longer contains proc, session, pcred, ucred, procsig, vmspace,
pstats, mtx, sigiolst, klist, callout, pasleep, or mdproc. If
any of these changed in size, ps, w, fstat, gcore, systat, and
top would all stop working. The new structure has over 200 bytes
of unassigned space for future values to be added, yet is nearly
100 bytes smaller per entry than the structure that it replaced.


# 69372 29-Nov-2000 jhb

Introduce a 'mtxname' keyword that displays the current mutex that a
process is blocked on or '-'.


# 50471 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 43208 26-Jan-1999 julian

Enable Linux threads support by default.
This takes the conditionals out of the code that has been tested by
various people for a while.
ps and friends (libkvm) will need a recompile as some proc structure
changes are made.

Submitted by: "Richard Seaman, Jr." <dick@tar.com>


# 42612 13-Jan-1999 julian

Re-enable the options in ps(1) that were disabled with the Linux
threads support.

Submitted by: "Richard Seaman, Jr." <dick@tar.com>


# 41931 19-Dec-1998 julian

Reviewed by: Luoqi Chen, Jordan Hubbard
Submitted by: "Richard Seaman, Jr." <lists@tar.com>
Obtained from: linux :-)

Code to allow Linux Threads to run under FreeBSD.

By default not enabled
This code is dependent on the conditional
COMPAT_LINUX_THREADS (suggested by Garret)
This is not yet a 'real' option but will be within some number of hours.


# 39160 14-Sep-1998 dfr

Portability fixes when sizeof(int) != sizeof(long).


# 36352 25-May-1998 steve

If no value is present for the login name set it to '-'.
Also pretty-up the display of 'ps -Ortprio'.

PR: 4947
Submitted by: Martin Kammerhofer <dada@sbox.tu-graz.ac.at>


# 28054 11-Aug-1997 steve

Oops, add #include's (forgotten in last commit) to make this
compile again.


# 28052 11-Aug-1997 steve

Remove #ifdef NEWVM code and remove extra "key.name = p" line.


# 28051 11-Aug-1997 steve

Fix seg fault when invalid keywords are used.

PR: bin/4253
Submitted by: Jesse Rosenstock <jmr@ugcs.caltech.edu>


# 25271 29-Apr-1997 jkh

Dynamically adjust size of displayed username to the longest username which
appears, not the longest _maximum_ username (this should probably also go
into 2.2, for the day when we bump up the username length there too).

Submitted-By: Terry Lambert <terry@lambert.org>


# 23363 03-Mar-1997 ache

Big usernames fixes


# 23321 03-Mar-1997 ache

Use MAXLOGNAME-1 for width because MAXLOGNAME includes NUL


# 22988 22-Feb-1997 peter

Revert $FreeBSD$ to $Id$


# 21673 14-Jan-1997 jkh

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# 20420 14-Dec-1996 steve

-Wall cleaning.


# 17367 31-Jul-1996 dg

Updated to match kernel changes for timer/run queue.


# 11890 28-Oct-1995 phk

I add #include <sys/user.h>


# 11021 26-Sep-1995 peter

Correct the alignment of the tty column, which was affected by my change to
allow more than two tty characters.

David Greenman pointed out that when a process that had been revoked from
it's controlling tty, the "-" sign was detached from any two-character
names.


# 10553 03-Sep-1995 peter

Increase the tty column width from 2 to 3 characters.

This gives us more room to breath with tty names, especially with drivers
that support large numbers of ports.. eg: specialix and digiboard.

This does not actually change the current tty names, it just allows room
for reporting more characters if the drivers use them.


# 3296 02-Oct-1994 dg

On second thought...back out previous commit.


# 3295 02-Oct-1994 dg

Include rtprio.h


# 3044 24-Sep-1994 dg

Added $Id$


# 2446 01-Sep-1994 dg

Added rtprio option/field.

Submitted by: Henrik Vestergaard Draboel


# 1557 26-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1556,
which included commits to RCS files with non-trunk default branches.


# 1556 26-May-1994 rgrimes

BSD 4.4 Lite bin Sources