History log of /freebsd-10-stable/bin/ps/
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
331471 24-Mar-2018 jhb

MFC 330872:
Add a "jail" keyword to list the name of a jail rather than its ID.

310121 15-Dec-2016 vangyzen

MFC r309676

Export the whole thread name in kinfo_proc

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.

Sponsored by: Dell EMC

304190 15-Aug-2016 kib

MFC r303423:
Force SIGSTOP to be the first signal reported after the attach.

304188 15-Aug-2016 jhb

MFC 302900,302902,302921,303461,304009:
Add a mask of optional ptrace() events.

302900:
Add a test for user signal delivery.

This test verifies we get the correct ptrace event details when a signal
is posted to a traced process from userland.

302902:
Add a mask of optional ptrace() events.

ptrace() now stores a mask of optional events in p_ptevents. Currently
this mask is a single integer, but it can be expanded into an array of
integers in the future.

Two new ptrace requests can be used to manipulate the event mask:
PT_GET_EVENT_MASK fetches the current event mask and PT_SET_EVENT_MASK
sets the current event mask.

The current set of events include:
- PTRACE_EXEC: trace calls to execve().
- PTRACE_SCE: trace system call entries.
- PTRACE_SCX: trace syscam call exits.
- PTRACE_FORK: trace forks and auto-attach to new child processes.
- PTRACE_LWP: trace LWP events.

The S_PT_SCX and S_PT_SCE events in the procfs p_stops flags have
been replaced by PTRACE_SCE and PTRACE_SCX. PTRACE_FORK replaces
P_FOLLOW_FORK and PTRACE_LWP replaces P2_LWP_EVENTS.

The PT_FOLLOW_FORK and PT_LWP_EVENTS ptrace requests remain for
compatibility but now simply toggle corresponding flags in the
event mask.

While here, document that PT_SYSCALL, PT_TO_SCE, and PT_TO_SCX both
modify the event mask and continue the traced process.

302921:
Rename PTRACE_SYSCALL to LINUX_PTRACE_SYSCALL.

303461:
Note that not all optional ptrace events use SIGTRAP.

New child processes attached due to PTRACE_FORK use SIGSTOP instead of
SIGTRAP. All other ptrace events use SIGTRAP.

304009:
Remove description of P_FOLLOWFORK as this flag was removed.

301148 01-Jun-2016 truckman

MFC r300648

Fix CID 1011370 (Resource leak) in ps.

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

276272 27-Dec-2014 kib

MFC r275745:
Add facility to stop all userspace processes.

MFC r275753:
Fix gcc build.

MFC r275820:
Add missed break.

270264 21-Aug-2014 kib

MFC r269656:
Implement and use proc_realparent(9).

MFC r270024 (by markj):
Correct the order of arguments passed to LIST_INSERT_AFTER().

For merge, the p_treeflag member of struct proc was moved to the end
of the structure, to keep KBI intact.

267904 26-Jun-2014 pluknet

MFC r267196:

Add support for inspecting process flags set in p_flag2.

266279 17-May-2014 bdrewery

MFC r265229,r265239:

Add -J to filter by matching jail IDs and names.

260195 02-Jan-2014 trasz

MFC r256838:

Don't test arrays for being NULL.

Sponsored by: The FreeBSD Foundation

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 27-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


248342 15-Mar-2013 joel

Add a few examples.

Obtained from: OpenBSD


246486 07-Feb-2013 kib

Document P_PPTRACE.

MFC after: 2 weeks


245635 19-Jan-2013 jhb

- Move 'showthreads' check out of fmt.c.
- Update shadow copy of fmt_argv() prototype in w.c and fix calls for
additional parameter.


245610 18-Jan-2013 jhb

Include the thread name along with the command name when displaying the
command name of a thread from a multi-threaded process that doesn't have
an available argument list (such as kernel processes) and threads display
is enabled via -H.

Reviewed by: alfred, delphij, eric@vangyzen.net
MFC after: 1 week


244154 12-Dec-2012 pjd

Use kern.max_pid sysctl to obtain maximum PID number instead of using local
define.

Reviewed by: jhb


240649 18-Sep-2012 zont

- Bump date.

Submitted by: pluknet
Approved by: kib (mentor)
X-MFC-With: r240645


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


239883 29-Aug-2012 emaste

Avoid passing uninitialized stack to addelem() if called with an empty arg.

PR: bin/171174


238488 15-Jul-2012 jilles

ps: Fix memory leak when showing start/lstart for swapped-out process.

Spotted by: scan-build (uqs)


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


233665 29-Mar-2012 joel

mandoc complains loudly when <TAB>s are misused in columnated lists. Fix
this syntax violation and while I'm here also convert <TAB> to Ta and adjust
quotation marks in order to prevent this problem in the future.


232694 08-Mar-2012 kib

Document P_ORPHAN.

MFC after: 3 days


230287 17-Jan-2012 ed

Remove unused variables.

Simply annotate the function parameters with __unused, instead of adding
the ve-variables. This makes the code build with GCC 4.7 and -Werror.


229782 07-Jan-2012 uqs

Spelling fixes for bin/


227846 22-Nov-2011 trociny

Remove yet another outdated note about procfs(5) being required.

Spotted by: arundel


227840 22-Nov-2011 trociny

No need in procfs(5).

MFC after: 2 weeks


226939 30-Oct-2011 trasz

For processes with no controlling terminal, display "-" in the TTY column
instead of "?".

Submitted by: arundel


225927 02-Oct-2011 gjb

Correct a typo that was introduced in 225912

Submitted by: Valentin Nechayev (netch % netch!kiev!ua), arundel
MFC after: 1 week
With-MFC: 225908


225912 01-Oct-2011 gjb

Tweaks to ps(1):
- there's no reason the semantics of the -x flag are being explained in
the -a flag description
- be more precise regarding the relation between the -a flag and the
security.bsd.see_other_uids sysctl
- describe the format of the -t flag's argument
- 'con' no longer is a possible entry in the 'TT' column
- explain that the 'TT' column refers to pseudo-terminals via mere numbers
- add a hint in the 'tt' keyword description that a keyword 'tty' exists,
which will give the full terminal pathname

Submitted by: arundel (via docs@) (original)
MFC after: 1 week
With-MFC: 225908


225908 01-Oct-2011 gjb

Reorder default ps(1) output according to reality.

Submitted by: arundel (via docs@)
MFC after: 1 week


225868 29-Sep-2011 trasz

Make ps(1) automatically size its column widths.


225847 28-Sep-2011 ed

Get rid of major/minor number distinction.

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).


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)


223709 01-Jul-2011 pluknet

Bump date after the previous commit.


223708 01-Jul-2011 pluknet

Update and sort the list of the available keywords.


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>


222178 22-May-2011 uqs

Fix some typos under bin/

Found by: codespell


222130 20-May-2011 pluknet

Spelling in P_HADTHREADS.

MFC after: 1 week


222127 20-May-2011 pluknet

Fix the description of the "paddr" keyword. It shows a process
pointer just like a dublicating "uprocp".

MFC after: 1 week


220799 18-Apr-2011 trasz

Document problems with -d/-w and the fact that -X is the default.

Suggested by: arundel@
Reviewed by: arundel@


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".


217821 25-Jan-2011 kib

Document P_FOLLOWFORK.

MFC after: 2 weeks


217192 09-Jan-2011 kib

Move repeated MAXSLP definition from machine/vmparam.h to sys/vmmeter.h.
Update the outdated comments describing MAXSLP and the process
selection algorithm for swap out.

Comments wording and reviewed by: alc


213536 08-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.


213012 22-Sep-2010 emaste

Correct sort order.


210448 24-Jul-2010 trasz

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

MFC after: 1 month


210447 24-Jul-2010 trasz

Add P_HASTHREADS flag description.


206548 13-Apr-2010 kib

Update the list of the process flags for P_WKILLED.

MFC after: 4 weeks


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


204755 05-Mar-2010 kib

Update the list of the process flags. Note that the lists of pending
signals for process and its threads are distinct.

Reviewed by: jilles
MFC after: 2 weeks


203688 08-Feb-2010 brucec

Initialize the execfile argument to NULL instead of _PATH_DEVNULL. This allows the -M option to be used without specifying -N.

PR: bin/138146
Approved by: rrs (mentor)
MFC after: 3 days


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.


195830 23-Jul-2009 brian

Add the -d switch to the usage message.

Submitted by: Emil Mikulic - emil at dmr dot ath dot cx
Approved by: re (kib)
MFC after: 1 week


195502 09-Jul-2009 trasz

Add manual page links to advertise procstat(1) a little better.

Approved by: re (kib)


192688 24-May-2009 jilles

Fix elapsed (etime) field for swapped out processes in ps:
show '-' instead of time since the Epoch.

PR: bin/123069
Submitted by: Vladimir Kozbin
Approved by: ed (mentor)
MFC after: 3 weeks


192280 18-May-2009 brian

Remove redundant whitespace


192239 17-May-2009 brian

Add a -d option to ps to display descendant info with the output.
This is similar to linux's -H (or -f) switch.

MFC after: 3 weeks


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


184925 13-Nov-2008 emaste

Fix whitespace.


180596 18-Jul-2008 kevlo

Remove unnessasary cast


177090 12-Mar-2008 jeff

- P_SA has been removed.


173492 08-Nov-2007 jhb

Teach ps(1) to parse pts TT values (i.e. '0', '1') for the -t flag.

MFC after: 1 week
Reported by: kris


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.


172207 17-Sep-2007 jeff

- Move all of the PS_ flags into either p_flag or td_flags.
- 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)


162379 17-Sep-2006 ru

Markup fixes.


161491 21-Aug-2006 yar

For the sake of clarity, explicitly tell that comma and space
characters can be included in a custom column title string --
that's why it may appear at the end of a keyword list argument
only.


161442 18-Aug-2006 yar

Document a detail in the present syntax of "ps -o foo=bar". Now
the header title string "bar" extends to the end of the argument
even if it contains commas or spaces, unlike in RELENG_4 or earlier.
The modern syntax agrees with SUSv3.

MFC after: 3 days


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


155876 21-Feb-2006 cognet

For pts, print the pts number, instead of the full name. As it was, we ended
up always printing "pts".

Submitted by: Michal Mertl <mime at traveller dot cz>


145675 29-Apr-2005 maxim

o Typo: s/teminal/terminal/.

Submitted by: Michal Varga


143872 20-Mar-2005 pjd

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

Reviewed by: gad
MFC after: 3 days


141917 14-Feb-2005 delphij

Several improvements to ps.1:
- Document the fact that empty heading text suppresses the
heading line (e.g. 'ps -o pid='), as this is very useful
in scripts.
- Describe logname keyword more completely.
- Describe the printing of arguments more completely.
- Put lockname in the correct alphabetical order in the list
of all keywords.
- Correct sentence in standards section.

Submitted by: Jilles Tjoelker <jilles at stack nl>
PR: docs/73618
MFC After: 1 week


141578 09-Feb-2005 ru

Sync program's usage() with manpage's SYNOPSIS.


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


140903 27-Jan-2005 delphij

ps(1) is WARNS=6 on all Tier-1 platforms as far as I can test,
so use default WARNS level from bin/Makefile.inc


139969 10-Jan-2005 imp

/*- or .\"- or #- to begin license clauses.


139171 22-Dec-2004 rwatson

Remove single line containing the word "KLD" ommitted in ps.1:1.80.

Pointed out by: ru (some time ago)


138191 29-Nov-2004 rwatson

Point at the mac(4) man page when describing the -Z option.
Remove reference to /dev/lomac, which is no longer used by mac_lomac(4).

MFC after: 3 days


137890 19-Nov-2004 csjp

Use statfs instead of getmntinfo(). This will make the procfs checks
play nicer in prisons. It also simplifies things.

Reviewed by: rwatson
Bumped into by: Jilles Tjoelker


137696 14-Nov-2004 csjp

Currently if the user specifies -e and procfs is not mounted on /proc,
printing of the process environment will fail silently.

-define a function which will check to see if procfs is mounted on /proc
-Implement this test if the user specified -e
-If procfs is not mounted on /proc and -e was specified, print a warning.
informing the user that procfs(5) is required.

Reviewed by: wes, rwatson


137670 13-Nov-2004 ru

Removed bitrot.


132433 20-Jul-2004 tjr

Use warn() instead of perror().


131215 27-Jun-2004 gad

Change the "rtprio" format so it prints an informative string for
the PRI_ITHD case (instead of just printing the digit '1').

Submitted by: Cyrille Lefevre


131209 27-Jun-2004 gad

Improve checking for `ps -t <dev>', and give better error messages when
an invalid <dev> is specified. Aside: It turns out that the S_ISCHR()
check is true for almost every device that we have (not just tty's).


131024 24-Jun-2004 gad

Fix a bug I introduced by some last-minute changes in -r 1.102. I ended
up checking the wrong variable for NULL.

Submitted by: bde


131010 24-Jun-2004 gad

Rework the logic for `-t <tty>', such that it accepts "ttyp0" and "console",
in addition to "/dev/ttyp0" or "p0" and "/dev/console" or "co".


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


130991 23-Jun-2004 gad

Add a check for defunct processes in saveuser(), so the output for "args"
(aka "command") will display "<defunct>", as does the output from "comm"
for those processes. Also do better checking for malloc() failures.

Submitted by: Cyrille Lefevre


130975 23-Jun-2004 gad

Avoid padding the value of "ucomm" when it is the last column in the line.

Submitted by: Cyrille Lefevre


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


130973 23-Jun-2004 gad

Include the `-c' option in the usage() message.

Submitted by: Cyrille Lefevre


130972 23-Jun-2004 gad

In the sorting routine, sort by thread-id if two processes have the same PID.

Submitted by: Cyrille Lefevre


130897 22-Jun-2004 gad

Get rid of a cast to '(void) ' on the return of a call to strcpy.


130896 22-Jun-2004 gad

Oops. Undo that last 'const' change. It expects similar changes to some
other files that I am not ready to commit yet...


130895 22-Jun-2004 gad

Add 'const' to a few places.

PR: bin/65803
Submitted by: Cyrille Lefevre


130894 22-Jun-2004 gad

When displaying the "COMMAND" field for system-processes and/or kernel
threads, put the command name in square brackets instead of parenthesis.
This matches NetBSD, and also seems to be what linux does. The sentence
which is added to the man page is taken straight from NetBSD.

PR: bin/65803
Submitted by: Cyrille Lefevre
Obtained from: NetBSD


130856 21-Jun-2004 gad

Have `ps' return the cputimes for zombies, with the assumption that
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


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


130828 20-Jun-2004 gad

From SUSv3:
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...)


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


130816 20-Jun-2004 gad

Have the main() routine calculate %CPU and (if needed) memory information
when copying per-process info before starting to sort the list. This way,
sort-by-CPU or sort-by-memory will only calculate values once-per-process,
instead of twice-per-comparison. Also take advantage of this to simplify
the pscomp() routine.


129971 01-Jun-2004 gad

Try to change the isdigitch() macro to something that Bruce won't roll
his eyes at quite so much... (actually someone else pointed this out
to me a long time ago, but apparently I never fixed it)


129967 01-Jun-2004 gad

A few more style-fixes from Bruce. The only non-cosmetic change
is to drop a call to setuid() which has not been needed for years.

Noticed by: bde


129953 01-Jun-2004 gad

Since I'm not ready to add the non-standard ADD_PS_LISTRESET feature,
remove the #ifdef for it for now. I might add the feature for real at
some later date, there isn't much reason for the #ifdef for now.


129952 01-Jun-2004 gad

Make a few style-istic improvements to the previous commits.

Noticed by: bde


129917 01-Jun-2004 gad

Fix so `ps' catches and complains about null-values specified for a
process id, instead of using pid==0. Ie, `ps -p 12,' and `ps -p ,12'
are now errors (instead of being treated like `ps -p 0 -p 12').

Noticed by: Cyrille Lefevre on freebsd-arch


129915 01-Jun-2004 gad

Additional tiny adjustment to kludge-option processing so `ps t p0'
is treated like `ps -t p0', instead of changing it to `ps -T p0'.
Note that `ps t' is still changed to `ps -T', since that is one of
the main reasons for this kludge processing...

Noticed by: Jilles Tjoelker on freebsd-arch


129914 01-Jun-2004 gad

Rewrite the kludge-option processing to improve how it handles a few
more special situations. This is the code which process `ps blah',
when "blah" does not include a leading '-'.

This change also removes a long-undocumented BACKWARD_COMPATIBILITY
compile-time option, where:
ps -options arg1 arg2
(with no '-' on "arg1" and "arg2") was treated as:
ps -options -N arg1 -M arg2

This also changes `ps' to check for any additional arguments after
processing all the '-'-options, and attempt to use those arguments as
a pid or pidlist. If an extra argument is not a valid pidlist, then
`ps' will print an error and exit. This seems a more generally useful
extension of the kludge-option processing than the -N/-M behavior, and
has fewer confusing side-effects.

Reviewed by: freebsd-arch


129714 25-May-2004 gad

Add pgrep(1) and pkill(1) to the cross-reference section of ps(1).


129635 23-May-2004 gad

Add the 'sid' info to the output of `ps -j', to make up for the 'sess'
(session-pointer) info which was dropped from `ps' earlier in 5.x.

PR: bin/59423
Submitted by: Jilles Tjoelker


129634 23-May-2004 gad

Fix the kludge-old-options processing so `ps tpt' will be treated the
same as `ps -tpt', instead of being changed into `ps -tpT'.

PR: bin/52489
Submitted by: Jilles Tjoelker
MFC after: 1 week


129600 22-May-2004 gad

Change `ps' to use the KERN_PROC_RGID and KERN_PROC_SESSION options
(if trying to match only one real-group or one session-id), now that
those options are implemented in src/sys/kern/kern_proc.c (v1.203).

PR: bin/65803 (a very tiny piece of the PR)
Submitted by: Cyrille Lefevre


129298 16-May-2004 ru

Assorted markup fixes.


127958 06-Apr-2004 markm

Remove clause 3 from the UCB licenses.

OK'ed by: imp, core


127844 04-Apr-2004 gad

Drop the include of <stdint.h>, since r1.84 removed references of intmax_t.


127843 04-Apr-2004 gad

Add back the `-e' option, which was mistakenly dropped when cleaning
up the PS_ARGS string in revision 1.69 (and which was apparently not
missed by anyone...).


127823 04-Apr-2004 gad

Give a name of 'l' (list) to the union in struct listinfo. This is
because some compilers (such as gcc 2.95.4) do not support having an
unnamed union for a field in a struct.


127710 01-Apr-2004 gad

Add spaces after flag names on .Fl macros.

Noticed by: ru
MFC after: 4 days


127693 31-Mar-2004 gad

Describe the sorting options in better and more complete detail.
Also improve the description of `-L' a little.

MFC after: 4 days


127602 30-Mar-2004 gad

Switch to using strtoul() for parsing a potential UID or GID, which gets
this to correctly handle UID's and GID's larger than 2147483647.

Noticed by: bde
MFC after: 1 week


127598 30-Mar-2004 gad

Bruce would really like the prototype for fmt() to be split across lines
this way (although I still think it "looks weird"...).

Requested by: bde
MFC after: 1 week


127597 30-Mar-2004 gad

Minor style fixes, mostly adding indent-protection on some comment-blocks.

Noticed by: bde
MFC after: 1 week


127596 30-Mar-2004 gad

Replace pscomp() with a cleaner version, mostly written by bde (*).
This corrects a problem of lost-precision for `-r' (sort-by-CPU). Also,
for sort-by-CPU and sort-by-memory, any processes which have the same
value CPU or MEMORY are now sorted by TTY and then (if needed) by pid.

(* - I just added the NODEV checks, after doing some testing of my own)

Submitted by: bde
MFC after: 1 week


127555 29-Mar-2004 gad

Oops. Remove some ';'s in #defines added by a previous update.

Noticed by: bde


127546 29-Mar-2004 gad

Have this source explicitly include <sys/proc.h>, since it references
values such as P_CONTROLT and PS_INMEM. But this still won't define
PID_MAX for us, since that is hidden inside of '#ifdef _KERNEL'.

Noticed by: bde


127544 29-Mar-2004 gad

Since "kp" is a pointer, I should be comparing against NULL not 0.

Noticed by: bde


127542 29-Mar-2004 gad

Various style improvements, mostly in comments and indentation.

Suggested by: bde (well, for most of them)


127539 29-Mar-2004 gad

In the routines I've been working on, sort the variable declartions
so that non-pointers are listed after pointer-type variables.

Noticed by: bde


127538 29-Mar-2004 gad

Split two 'fmt' strings so they're easier to read on 80-char windows.


127537 29-Mar-2004 gad

Sort the declarations of global variables.


127536 28-Mar-2004 gad

Sort the routine prototypes.


127513 28-Mar-2004 gad

If <x> is a process id that does not exist, then just print the header
(if any) and exit, thus matching the behavior on -stable and other OS's.
My earlier attempt to fix this (v1.65) only seemed to work because of a
lucky random value in nentries (which was not being initialized back
when I tested that earlier patch).


127512 28-Mar-2004 gad

Fix `-o rtprio' so it prints the correct value.

PR: bin/59417
Submitted by: Jan Willem Knopper
This fix by: bde (in the audit-trail of the PR)


127509 27-Mar-2004 gad

If a non-existent user is given as part of `-U userlist', treat it as
a fatal error instead of a minor warning. It is possible that a few
users are used to the previous behavior, but I'm claiming it was a bug.


127508 27-Mar-2004 gad

Explicitly wrap two long-ish linesi of code, to make them easier to read.


127507 27-Mar-2004 gad

Change the #if-ish logic which is used to add the `-f' option when `ps'
is compiled with LAZY_PS, so that there is only one PS_ARGS string to
modify when changing the option-list. Also get `-f' to show up in the
usage() statement when compiled with LAZY_PS.


127506 27-Mar-2004 gad

Move the 'f' case so it shows up in the right place, alphabetically.


127500 27-Mar-2004 gad

Update the date on the man page, since this the previous change added
a few new options.


127499 27-Mar-2004 gad

Support more POSIX/SUSv3 options:

- Change `-p' to allow a list of process IDs, and `-t' to allow a list
of terminal names, instead of only a single value for each.
- Add the `-A' option of SUSv3, which is exactly the same as `-ax'.
- Add the `-G gidlist' (group id).
- Allow any of these "selector options" to be specified multiple times,
and have `ps' keep adding to a given list -- instead of replacing the
previously-specified values.
- Fix interactions between selector-options, so that: "If any are
specified, ... ps shall select the processes represented by the
inclusive OR of all the selection-criteria options." (from SUSv3)
- Add a `-X' option, which is the reverse of the `-x' option.

- various minor improvements in parsing and error handling.

This does not get us to match POSIX/SUSv3, but it gets us closer. The
`-g pgidlist', `-R ruserlist' and `-s sidlist' options mentioned in
freebsd-standards are still under debate, so they skipped for now.
It should be true that this introduces no user-visible incompatible
changes, except to support "new stuff" that was not supported before.


127445 26-Mar-2004 ru

Avoid the manpage layering violation and low-level implementation
details of libkvm, and just tell what the getbootfile(3) function
will return, by using the text from netstat(1) and dmesg(8).


127440 26-Mar-2004 ru

- Remove references to /dev/kmem -- ps(1) utilizes the
sysctl(3) interface in kvm(3).
- Document the correct default when no -N is specified.
- Remove stale reference to /var/db/kvm_kernel.db.
- Remove stale reference to /var/run/dev.db.


127270 21-Mar-2004 tjr

Document incorrect handling of multibyte characters.


127155 18-Mar-2004 gad

Fix 'ps -p proclist' and 'ps -u userlist' so the command returns non-zero
if no processes were matched. Also sorts the list of 'int's in main, as
long as I had to add another one...

Noticed by: Nate Lawson
MFC after: 10 days


127149 17-Mar-2004 gad

Improvements to 'ps -p <x>'. If <x> is a process id that does not exist, then
just print the header (if any) and exit, thus matching the behavior on -stable
and other OS's.

Also adds support for <x> being a comma-separated list of processes, and does
a much better checking for invalid-values of <x>, such as 'ps -p someword'.

Reviewed by: mentioned on freebsd-current
MFC after: 10 days


126173 23-Feb-2004 johan

style.Makefile:
Use WARNS?= instead of WARNS=


126127 22-Feb-2004 deischen

Allow the -H option to show threads when selecting by uid, tty,
and pid.


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


124792 21-Jan-2004 cperciva

Bring ps.1 up to date with changes in the past seven years:
* Remove mention of '>', 'A', and 'S' states
* Mention 'W' state.
* List 'J' state in the correct location.
* Sync with flags in sys/proc.h

Approved by: rwatson (mentor)
MFC after: 7 days


119893 08-Sep-2003 ru

mdoc(7): Use the new feature of the .In macro.


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.


118481 05-Aug-2003 brueffer

Clarify that the 'state' information consists of characters, not
only letters (e.g. IWs+)

PR: 55221
Submitted by: Rich Morin <rdm@cfcl.com>
MFC after: 3 days


116282 13-Jun-2003 markm

Get this area compiling with the highest WARNS= that it works with.
Obsolete WFORMAT= junk also removed where possible.

OK'ed by: obrien
Tested on: sparc64, alpha, i386


116265 12-Jun-2003 scottl

Add the -H option to ps(1) to display all kernel visible threads in each
process. The default behavior of showing only the process is retained as
the default.


116019 08-Jun-2003 charnier

add section name to .Xr


114600 03-May-2003 markm

Fix long constant usage for i386.

Tested by: Joe Marcus Clarke <marcus@marcuscom.com>


114583 03-May-2003 markm

Fix a bazillion warnings. This makes almost the whole of src/bin/*
WARNS=6, std=c99 clean.

Tested on: i386, alpha


114483 02-May-2003 obrien

fmt.c has a comparison between signed and unsigned that is unclear how
to properly fix.


114318 30-Apr-2003 schweikh

Fix references to non-existing or obsoleted man pages.

PR: docs/51480 (only a small part)
Submitted by: Diomidis D. Spinellis <dds@aueb.gr>


113524 15-Apr-2003 charnier

Revert the zombie part of previous commit


113485 14-Apr-2003 charnier

Correct style bugs. Don't skip zombies in cputime(), according to Bruce,
zombie CPU times are valid. Adjust array size in strftime(3).

Submitted by: Bruce


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 19-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 19-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>


109460 18-Jan-2003 jmallett

Refer to the process label as proclabel, as there is a function called label,
and that's what these locals were called before.


108221 23-Dec-2002 ru

Fixed the abuses of .Ql visible on stderr in troff mode.

PR: docs/37176


106318 01-Nov-2002 tmm

The hw.availpages sysctl has an unsigned long value now, fix the retrieval
to match that.


106251 31-Oct-2002 tjr

Do not print a header line if it would be empty; required by 1003.1-2001.


105831 24-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


104414 03-Oct-2002 bde

Oops, the previous version was a last minute test version with off_t
replaced by int instead of size_t.

Spotted by: fanf


104411 03-Oct-2002 bde

Use a non-bogus type for representing the values of offsets in structs.
off_t is for offsets in files, and it is signed so it was no better
than the original type of int for avoiding warnings from broken lints,
except accidentally on machines like i386's where size_t is smaller
than off_t.


104388 02-Oct-2002 jhb

Catch up to SMTX -> SLOCK changes.


104026 27-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 27-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.


103274 13-Sep-2002 peter

Do not risk using the kernel pgtok() which assumes the page size is
constant.


102886 03-Sep-2002 jmallett

Prevent ps(1) from doing idiotic munging of things in a -ofmt= string.

God I hate the backwards compatability crap here.


102230 21-Aug-2002 trhodes

s/filesystem/file system/ as discussed on -developers


101572 09-Aug-2002 ru

mdoc(7) police: whitespace nits.


99785 11-Jul-2002 bde

Fixed a printf format error that was fatal on alphas. Adding WFORMAT=0
to the Makefile didn't affect this bug because WFORMAT only controls
higher- level format checking (not the -Wformat that is implicit in
-Wall).

Fixed a nearby printf format error that was benign and 3 nearby style bugs.


99744 10-Jul-2002 dillon

err() is documented as allowing NULL for the format string but GCC isn't
happy about it any more so change the usage to make buildworld work again.


99592 08-Jul-2002 jmallett

Bring back WFORMAT=0.


99580 08-Jul-2002 robert

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


99547 07-Jul-2002 jmallett

Make printval() take a 'void *' thus negating any assumptions the compiler
may try to make about the alignment of the dereferenced datum.


99457 05-Jul-2002 mike

Don't depend on pollution in <limits.h> for the definition of
<stdint.h> macros.


99110 30-Jun-2002 obrien

Consistently use FBSDID


98494 20-Jun-2002 sobomax

Don't try to decode old-style options if the argv[1] begins with `-' and the
second character represents some option taking an argument. This fixes
problem when ps(1) is invoked for examply as follows:

$ ps -Ufoobar1234

the above example results in option string being interpreted as
-U foobarp1234 - note extra `p'.

Reported by: Vladimir Sotnikov <vovan@kyivstar.net>
MFC after: 2 weeks


98106 10-Jun-2002 jmallett

ps(1) appeared in v4

Submitted by: grog


98080 10-Jun-2002 jmallett

Note early appearence of some commands. These actually appeared in PWB, but
it seems we don't have a macro for that yet, so list them in the first UNIX
release since then that we have a .At for: v7.


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


98030 08-Jun-2002 bde

Fixed unsorting.


98029 08-Jun-2002 jmallett

Don't say that the list of formats can be space delimited, it no longer can be.

Mention that more than one -o will concatenate formats.

Submitted by: Jun Kuriyama <kuriyama@imgsrc.co.jp>


97978 07-Jun-2002 jmallett

Back out previous back out of previously correct code.

Double-plus-pointy-hat to: jmallett
Submitted by: bde


97972 07-Jun-2002 jmallett

Remove tunables to hide warnings that no longer exist.


97971 07-Jun-2002 jmallett

Cast to long to match format. Hidden by revision 1.18 of Makefile.


97966 06-Jun-2002 jmallett

Use a global `now' variable for the current time, and initialise it at
startup, right after calling setlocale(3).


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.


97964 06-Jun-2002 jmallett

sysctlbyname(3) returns -1 on failure, not any other value < 0.


97961 06-Jun-2002 jmallett

Support the SUSv3 `rgroup' format.

Clean up some local style bogons.


97959 06-Jun-2002 jmallett

Cast arg_max to size_t when comparing it (times 4, plus 1) against SIZE_MAX. I
was worried about truncation of arg_max by this cast, but if it gets truncated,
we know it'll obviously be greater than SIZE_MAX anyway.

Big pointy hat to: jmallett
Submitted by: keramida


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.


97945 06-Jun-2002 jmallett

Refer to the command format by its SUSv3 name (comm), and list command as an
alias.


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


97875 05-Jun-2002 jmallett

Comma seperate format lists, since space is no longer up to the task.

Poked by: David Wolfskill <david@catwhisker.org>
Pointy hat to: jmallett


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 05-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


97847 05-Jun-2002 jmallett

Returning NULL here if malloc(3) fails is silly, at this point in the codepath
we have't malloc(3)'d nearly as much as we probably will, so errx(3) away,
instead of waiting for something to fail yet again later on.


97846 05-Jun-2002 jmallett

Remove an XXX comment that seems to be a tiny bit no longer pertinent. This
function seems to do the right thing, and is not a "stub", and whoever "marc"
is, he's had plenty of time to do "the real one", so don't wait around for
him any longer.


97845 05-Jun-2002 jmallett

Use of zero here meant many things, NULL, '\0' (NUL), and 0. Sort it out.


97843 05-Jun-2002 jmallett

Use a const char * where it is meant to be used. There's no reason to try
to discard the const qualifier here.


97842 05-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.


97804 04-Jun-2002 tjr

Respect setting of the COLUMNS environment variable (SUSv3)


96729 16-May-2002 joe

The sysctl has changed from 'kern.ps_showallprocs' to
'security.bsd.see_other_uids'.


96702 16-May-2002 trhodes

Consistancy check s/file system/filesystem/

Reviewed by: brian


96247 09-May-2002 joe

Replace /kernel with /boot/kernel/kernel.

PR: docs/37757
Submitted by: Hiten Pandya <hiten@uk.FreeBSD.org>


96053 05-May-2002 jmallett

Check for possible overflow from sysconf _SC_ARG_MAX and error out in a
correct manner. Revert my incorrect change to use err(3) for malloc(3)
failing. Use a size_t variable to store the size of the argument buffer
we allocate, and remove silly casts as the result of having this around.
Modify the math in some of the paranoid checks for buffer overflow to
account for the fact we now are dealing with the actual size of the
buffer. Remove the static qualifier for arg_max, and the bogus setting
of it to -1.

Include <limits.h> for the definitions we use to check for possible
overflows.

Submitted by: bde


95921 02-May-2002 jmallett

Don't cast incorrectly to malloc(3), and don't use errx(3) if malloc(3)
returns NULL, as malloc(3) sets errno. Use err(3).


94869 16-Apr-2002 charnier

Use `The .Nm utility'


94030 07-Apr-2002 jedgar

errx()/strerror() -> err()


93229 26-Mar-2002 ru

Install sys/security/lomac/*.h to /usr/include/security/lomac/.

Install sys/<arch>/include/pc/*.h to /usr/include/machine/pc/.

PR: docs/29534

Install sys/netatm/*/*.h to /usr/include/netatm/*/.

Don't install compatibility symlinks for <machine/soundcard.h>
and <machine/joystick.h>. Three years is enough to be aware of
the change, and these weren't visible in the SHARED=symlinks
case.

Back out include/Makefile,v 1.160 that was a null change anyway
due to the bug in the path, and we now don't want to install
these headers because they would otherwise be invisible in the
SHARED=symlinks case.

Don't install IPFILTER headers. Userland utilities fetch them
directly, and they were not visible in the SHARED=symlinks case.

Resurrect SHARED=symlinks in Makefile.inc1.

PR: bin/28002

Prodded by: bde
MFC after: 2 weeks


92294 14-Mar-2002 rwatson

NAI DBA update.


91171 23-Feb-2002 bde

Fixed unsorting.


91089 22-Feb-2002 markm

ANSIfy.


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>


90878 19-Feb-2002 imp

Fixed divots that I created when I moved prototypes of group_from_gid
and user_from_uid to grp.h and pwd.h. Update the man pages.

Submitted by: David Malone
Pointy hat to: imp


90740 16-Feb-2002 dillon

When blocked on a mutex, display the mutex name via the wchan string field
so we can at least tell the difference between being blocked in Giant
and being blocked in some other mutex.


90738 16-Feb-2002 des

Document the 'M' state.


90167 04-Feb-2002 kris

Correct inadvertent style botches in previous commit.


90166 04-Feb-2002 kris

Lock down with WFORMAT=1 except those directories with unfixed warnings.
Tested on i386 and alpha.


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.


89918 28-Jan-2002 ru

Remove a stray `:' after `v' in the getopt() call.

Submitted by: bde


89909 28-Jan-2002 ru

GC the -W option. kvm(3) doesn't read swap for almost 10 years.

PR: docs/34134
Reviewed by: bde, peter
MFC after: 1 month


89575 20-Jan-2002 mikeh

Prevent overflowing the buffer that stores the command arguments.

PR: bin/19422
Not objected to by: -audit
MFC after: 3 weeks


89389 15-Jan-2002 sobomax

Add missed includes.

Reviewed by: md5


88904 05-Jan-2002 peter

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


87353 04-Dec-2001 ru

mdoc(7) police: s/LKM/KLD/, sort xrefs.


87323 04-Dec-2001 obrien

Default to WARNS=2. Binary builds that cannot handle this must explicitly
set WARNS=0.

Reviewed by: mike


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


83366 12-Sep-2001 julian

KSE Milestone 2
Note ALL MODULES MUST BE RECOMPILED
make the kernel aware that there are smaller units of scheduling than the
process. (but only allow one thread per process at this time).
This is functionally equivalent to teh previousl -current except
that there is a thread associated with each process.

Sorry john! (your next MFC will be a doosie!)

Reviewed by: peter@freebsd.org, dillon@freebsd.org

X-MFC after: ha ha ha ha


83280 10-Sep-2001 peter

UPAGES as a constant is gone in KSE. We are going to have to trust
and/or fix ki_rssize.


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".


82267 24-Aug-2001 peter

Handle kvm_getprocs() returning nothing. Dont pass -1 to a size
for malloc().


81743 16-Aug-2001 brian

Only capitalise the last `t' in ps's first argument when it's
actually part of an option argument.

Submitted by: Chris Costello <chris@calldei.com>
MFC after: 6 weeks


79526 10-Jul-2001 ru

mdoc(7) police: removed HISTORY info from the .Os call.


78363 16-Jun-2001 tegge

Check for the PS_SINTR flag in the right field of struct kinfo_proc
(ki_sflag).


77896 08-Jun-2001 dd

Correct a typo.

Submitted by: Alexey V. Neyman <avn@any.ru>


77609 02-Jun-2001 dd

Mention the kern.ps_showallprocs sysctl.

PR: 24804
Submitted by: Mike Meyer <mwm@mired.org>


77459 30-May-2001 imp

Use PATH_MAX rather than MAXPATHLEN.


76812 18-May-2001 ru

Removed -I${.CURDIR}/.../sys from CFLAGS.


76245 03-May-2001 markm

Depollute headers now that the VM headers DTRT.


76168 01-May-2001 markm

Compensate for header dethreading.


75449 12-Apr-2001 brian

Correct some markup

Submitted by: bde


75435 11-Apr-2001 brian

Introduce -osid and -otsid

Submitted by: dd


75287 07-Apr-2001 brian

Remove tsess for now.

This (and sess) may come back shortly.


75285 07-Apr-2001 brian

Update documentation in line with what the code does

PR: 25435
Submitted by: dd
Forgotten by: mckusick


75279 07-Apr-2001 brian

The sess column went away last December with v1.26 of keyword.c
Remove it from ``jfmt''.

Forgotten by: mckusick


73369 03-Mar-2001 ache

Small optimization: set use_ampm only when needed


73367 02-Mar-2001 ache

Use AM/PM time only when available in locale


73219 28-Feb-2001 obrien

Fix style bug I introduced with rev 1.13 (rcsid after includes).
Along with CSRG id lossage in rev 1.11.

Submitted by: bde


73143 27-Feb-2001 obrien

Add rcsid.


72489 14-Feb-2001 jlemon

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

Submitted by: rgrimes
Obtained from: NetBSD


72377 12-Feb-2001 jake

Catch up to new priority interface.


72343 11-Feb-2001 ache

Use decimal point from locale


71895 01-Feb-2001 ru

mdoc(7) police: split punctuation characters + misc fixes.


71578 24-Jan-2001 jhb

- Catch up to new proc flags.


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>


70056 15-Dec-2000 ru

Prepare for mdoc(7)NG.


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.


69404 30-Nov-2000 jhb

Document the mtxname keyword.

Reviewed by: sheldonh


69372 29-Nov-2000 jhb

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


68935 20-Nov-2000 ru

mdoc(7) police: use the new features of the Nm macro.


67870 29-Oct-2000 jedgar

Remove obsolete /dev/drum references

Reviewed by: alex, asmodai, billf


66417 28-Sep-2000 kris

No need to work around SCCS variable expansion any more.


66377 26-Sep-2000 brian

Support multiple (comma separated) names as arguments to -U

PR: 11051


65557 07-Sep-2000 jasone

Major update to the way synchronization is done in the kernel. Highlights
include:

* Mutual exclusion is used instead of spl*(). See mutex(9). (Note: The
alpha port is still in transition and currently uses both.)

* Per-CPU idle processes.

* Interrupts are run in their own separate kernel threads and can be
preempted (i386 only).

Partially contributed by: BSDi (BSD/OS)
Submissions by (at least): cp, dfr, dillon, grog, jake, jhb, sheldonh


62803 08-Jul-2000 will

Fix the exit code for the case where nentries == 0; if a PID doesn't exist,
ps(1) should not be returning a success code (0), it should return an
error code (1). This was fixed on OpenBSD over 3 years ago.

PR: 19069
Submitted by: Jim Sloan <odinn@atlantabiker.net>
Reviewed by: rwatson


53278 17-Nov-1999 peter

I'm probably jumping the gun, but what the heck, this is -current.
Turn off setgid-kmem for /bin/ps, it's now quite functional without it.
ps no longer needs /dev/*mem or /proc. (It will still use some /proc
files if they are available for -e, but it's not required, so it'll
happily run in a jail or chroot).

The proc stats are now part of eproc (obtained via sysctl) and no longer
needs to beat up the u-page reading code and the problems with that.

This also has the side effect of disabling 'ps -e' for normal users
*EXCEPT* when looking at their own processes. ie: they can see
environments in processes with their uid, enforced by the ownership of
/proc/*/mem. Root can still see them all, as it can open all /proc/*/mem.


53276 17-Nov-1999 peter

Use eproc.e_stats, not a series of crude hacks to fetch it from the u-area.
Also, fix some indentation that got messed up somehow..


53239 16-Nov-1999 phk

Introduce commandline caching in the kernel.

This fixes some nasty procfs problems for SMP, makes ps(1) run much faster,
and makes ps(1) even less dependent on /proc which will aid chroot and
jails alike.

To disable this facility and revert to previous behaviour:
sysctl -w kern.ps_arg_cache_limit=0

For full details see the current@FreeBSD.org mail-archives.


53170 15-Nov-1999 kris

Typo (appropiate -> appropriate)

Obtained from: OpenBSD (inspired by)


50471 27-Aug-1999 peter

$Id$ -> $FreeBSD$


48366 30-Jun-1999 kris

Correct reference to the obsolete vadvise() to madvise() (with appropriate
arguments)

PR: 11586
Submitted by: David Gilbert <dgilbert@velocet.ca>
Reviewed by: Doug Rabson


46684 08-May-1999 kris

Various spelling/formatting changes.

Submitted by: Philippe Charnier <charnier@xp11.frmug.org>


46155 28-Apr-1999 phk

This Implements the mumbled about "Jail" feature.

This is a seriously beefed up chroot kind of thing. The process
is jailed along the same lines as a chroot does it, but with
additional tough restrictions imposed on what the superuser can do.

For all I know, it is safe to hand over the root bit inside a
prison to the customer living in that prison, this is what
it was developed for in fact: "real virtual servers".

Each prison has an ip number associated with it, which all IP
communications will be coerced to use and each prison has its own
hostname.

Needless to say, you need more RAM this way, but the advantage is
that each customer can run their own particular version of apache
and not stomp on the toes of their neighbors.

It generally does what one would expect, but setting up a jail
still takes a little knowledge.

A few notes:

I have no scripts for setting up a jail, don't ask me for them.

The IP number should be an alias on one of the interfaces.

mount a /proc in each jail, it will make ps more useable.

/proc/<pid>/status tells the hostname of the prison for
jailed processes.

Quotas are only sensible if you have a mountpoint per prison.

There are no privisions for stopping resource-hogging.

Some "#ifdef INET" and similar may be missing (send patches!)

If somebody wants to take it from here and develop it into
more of a "virtual machine" they should be most welcome!

Tools, comments, patches & documentation most welcome.

Have fun...

Sponsored by: http://www.rndassociates.com/
Run for almost a year by: http://www.servetheweb.com/


45367 06-Apr-1999 peter

Update p_flags doc.


45366 06-Apr-1999 peter

Look at p_lock instead of P_NOSWAP etc as an indicator of unswappability.
(While here, put a #ifndef pgtok around the macro that gets a redefinition
warning)


45227 01-Apr-1999 wpaul

On FreeBSD/alpha, ps(1) does not correctly report process start times
and CPU runtime because it can't access the user area via /proc/<pid>/mem.
This is because the uarea is not mapped into the process address space
at USRSTACK on the alpha like it is on the x86.

Since I'm haven't been able to wrap my brain around the VM system enough
to be able to figure out how to achieve this mapping, and since it's
questionable that such an architectural change is correct, I implemented
a workaround to allow ps(1) to read the uarea from /dev/kmem using
kvm_read() instead of from the process address space via kvm_uread().
The kludge is hidden inside #ifdef __alpha__/#endif so as not to impact
the x86. (Note that top(1) probably uses this same gimmick since it works
on FreeBSD/alpha.)

Reviewed by: dfr


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.


41580 07-Dec-1998 bde

Fixed -Wall regression (broken in rev.1.12). Removed unused includes.


41324 25-Nov-1998 dfr

Fix formatting of %CPU value on alpha.

Submitted by: Hidetoshi Shimokawa <simokawa@sat.t.u-tokyo.ac.jp>


39160 14-Sep-1998 dfr

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


39053 10-Sep-1998 bde

Fixed breakage of %CPU and %MEM in the previous commit. sysctlbyname()
was called with wrong args so it always failed.

PR: 7881


37317 30-Jun-1998 phk

Pick up kernel variables/constants using sysctl rather than through /dev/mem

Use /dev/null for opening the kvm library, we don't need access to /dev/mem
anymore.

ps can now run without the setgid(kmem) bit. If it does it will not be
able to show argv/envp for another uid's processes unless you are root.


37246 28-Jun-1998 bde

Fixed printf format errors (second round with non-i386 typedefs).


37232 28-Jun-1998 bde

Oops, the previous log message should have read "Fixed type mismatches -
don't assume that time_t is long".


37231 28-Jun-1998 bde

Fixed printf format errors.


37027 17-Jun-1998 jkoshy

Remove compile time dependency on ARG_MAX.

PR: 1791 (partial)
Reviewed by: Bruce Evans <bde@freebsd.org>, Tor Egge <tegge@freebsd.org>


36635 04-Jun-1998 jkoshy

Fix errors that crept into the previous commit.


36631 04-Jun-1998 jkoshy

1. `ps' output now shows 3 characters in the `TT' field, not 2, after
rev 1.6 of "ps.c".
2. Reword description of `-f' option.

PR: 5340
Submitted by: Jorge Goncalves <j@bug.fe.up.pt>


36497 31-May-1998 bde

Fixed imperfections in previous commit (a poor variable name,
excessive 64-bit arithmetic, and excessive changes).


36441 28-May-1998 phk

Some cleanups related to timecounters and weird ifdefs in <sys/time.h>.

Clean up (or if antipodic: down) some of the msgbuf stuff.

Use an inline function rather than a macro for timecounter delta.

Maintain process "on-cpu" time as 64 bits of microseconds to avoid
needless second rollover overhead.

Avoid calling microuptime the second time in mi_switch() if we do
not pass through _idle in cpu_switch()

This should reduce our context-switch overhead a bit, in particular
on pre-P5 and SMP systems.

WARNING: Programs which muck about with struct proc in userland
will have to be fixed.

Reviewed, but found imperfect by: bde


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>


36049 15-May-1998 charnier

Correct use of .Nm. Add rcsid.


33592 18-Feb-1998 dima

Add 'f' flag to the optstring.


33591 18-Feb-1998 dima

cosmetic change for optstring


33010 02-Feb-1998 dyson

Display VSZ much more accurately now.


31553 05-Dec-1997 dyson

Document the new -f flag.
PR: 5196
Submitted by: Matt Dillon <dillon@best.net>


31552 05-Dec-1997 dyson

Add an option to building PS, so that the upages are explicitly paged in only
for users who are root, or in group wheel. This is useful on large timesharing
systems where a PS command can cause the system to grind to a halt. The
ability to get the information isn't diminished for those who really need the
additional detail (administrators.) Normal users won't see any difference unless
the processes are swapped out. The "really get it mode" is invoked by the
use of an additional flag in the command string "-f". New/old behavior is
selectable with a compile option.

PR: 5196
Submitted by: Matt Dillon <dillon@best.net>


28433 19-Aug-1997 jlemon

Document correct option in manual page.

PR: 3769
Submitted by: johnp@lodgenet.com


28170 13-Aug-1997 steve

Use -I${.CURDIR}/../../sys so that the path is relative
to the source code directory.

Submitted by: bde


28054 11-Aug-1997 steve

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


28053 11-Aug-1997 steve

Use -I../../sys instead of -I/sys.


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>


27857 03-Aug-1997 peter

Fix "lstart". (Displays "19" rather than time)

PR: 4206
Submitted by: Tetsuya Furukawa <tetsuya@secom-sis.co.jp>


27856 03-Aug-1997 peter

Kill #ifndef NEWVM etc. It affected a lot of other things besides
VM structure (eg: credentials etc) and it's highly unlikely we'll ever
get to see the "tainted" BSD<=4.3 VM code in public use. Although it
indicated the way some things used to be done, it obfuscates things too
much.


27357 13-Jul-1997 bde

devname.c moved to libc before Lite1 and isn't in ps in Lite2.


26465 06-Jun-1997 charnier

Cosmetic change in usage string.


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>


24983 16-Apr-1997 jdp

When "-c" is specified, don't pad the command with spaces if it is
the last field on the line. "ps -axlc" was needlessly wrapping
around on 80-character windows.


24348 28-Mar-1997 imp

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


23610 10-Mar-1997 guido

Fix buffer overflow (probably unexploitable).


23363 04-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.


19596 10-Nov-1996 hsu

Remove unneeded #include <sys/proc.h>.


19068 21-Oct-1996 peter

Implement a -c option to ps to display the short command name instead of
the full argument vector.

I've bumped into a few things that expected this switch to be present,
the most recent was the snmp package in ports. I'm not 100% sure of the
origins of this, but Linux has it, so does the "BSD-compatable" version
of ps on our SVR4 systems (so I assume SunOS has it too).


17367 31-Jul-1996 dg

Updated to match kernel changes for timer/run queue.


16949 03-Jul-1996 mpp

The default swap device is /dev/drum, not /dev/swap
as ps.1 states.

Submitted by: Zahemszhky Gabor <zgabor@code.hu>


16835 29-Jun-1996 peter

Make %CPU add up closer to 100%.. At least, it now agrees with top.. :-)

Pointed out by: bde


16833 29-Jun-1996 peter

Fix (I think) the %MEM count in 'ps -u'. It was bogusly taking the
vm_rssize (in pages, not bytes), then dividing (bogusly) by the page size,
then using that as a fraction of the total pages.


15541 02-May-1996 phk

CLSIZE -> getpagesize()


15527 02-May-1996 phk

Replace NBPG with getpagesize()


15319 19-Apr-1996 smpatel

Fix up the badly out of date struct proc's p_flags.
Flags aren't printed in hexadecimal, as documented.


15073 06-Apr-1996 mpp

Correct some cross references and some path names.


13851 02-Feb-1996 mpp

Fix some incorrect locations in the FILES sections of some man pages.


13514 20-Jan-1996 mpp

Use the correct buffer size from limits.h for the error buffer
passed to kvm_open. Closes PR# 476.

Submitted by: Jeffrey Hsu <hsu@freebsd.org>


13399 12-Jan-1996 peter

oops. I forgot to add the "[-U username]" option to the usage string.


13117 30-Dec-1995 joerg

Small man page tweaks:

. mention the need for procfs
. make it clear that default sorting is first by ctty, then by PID

Submitted by: schweikh@ito.uni-stuttgart.de (Jens Schweikhardt)


13020 26-Dec-1995 peter

Implement a new option to ps.. `-U username'. This allows you to
list the processes belonging to a particular user without having to use
`-u' and grepping for the username. Basically you can now get a short
`ps -x' like list (with more space for the command) for other users.


11890 28-Oct-1995 phk

I add #include <sys/user.h>


11809 26-Oct-1995 ache

Change local to LC_ALL, there is no bitmask


11779 25-Oct-1995 torstenb

fix bad dependencies (LIBMATH -> LIBM)


11744 23-Oct-1995 ache

Add setlocale LC_CTYPE|LC_TIME


11743 23-Oct-1995 ache

Remove unneded ctype.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 04-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.


9987 07-Aug-1995 wollman

Delete bogus referneces to timezone code internal header file `tzfile.h',
which is no longer bogusly installed in /usr/include.


8855 30-May-1995 rgrimes

Remove trailing whitespace.

Reviewed by: phk


7837 15-Apr-1995 dg

Install with default BINOWN (as it once used to be).


7836 15-Apr-1995 dg

Install setgid kmem rather than setuid root. The problem with procfs that
was breaking this before has been fixed.


7165 19-Mar-1995 joerg

You will find enclosed some changes to make gcc -Wall more happy in
/usr/src/bin. Note that some patches are still needed in that directory.

I (Joerg) finished most of Philippe's cleanup. /bin/sh will still
need *allot* of work, however.

Submitted by: charnier@lirmm.fr (Philippe Charnier)


6971 09-Mar-1995 dg

Fix previous fix that removes an unnecessary space; the output is now
just like it was in 1.1.5.


4794 24-Nov-1994 dg

Re-apply an old patchkit days fix of mine for mempages:

* PATCHES MAGIC LEVEL PATCH THAT GOT US HERE
* -------------------- ----- ----------------------
* CURRENT PATCH LEVEL: 1 00051
* -------------------- ----- ----------------------
*
* 14 Aug 92 David Greenman Fixed NEWVM mempages calculation


4347 10-Nov-1994 ats

Fix an error to prevent some core dumps from ps.
You can get ps easily to core dump, if you are running a "make depend"
on a kernel in one window and a "ps -auxww" in another. The ww will
try to give you the full argument list of the command that can
now be 64Kb large, but ps expected only 4Kb large arg arrays and
doesn't check for overflows.


3686 18-Oct-1994 dg

Use kvm_uread instead of kvm_read to access the upages.


3301 02-Oct-1994 ache

Skip 'cua' 3 chars like 'tty' 3 chars


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


2110 18-Aug-1994 dg

Got rid of extra space between args and (command).


2032 11-Aug-1994 wollman

Make `ps' set-uid root so that it can read the same set of arguments
that old `ps'es did. I'm not too thrilled about this, but I'm not
enough of an FS person to hack procfs so that /proc/xxx/mem is readable
by members of group `kmem'. If this is done, then `ps' can go back to
being set-gid kmem.


1856 05-Aug-1994 dg

Converted 'vmunix' to 'kernel'.


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.