xref: /original-bsd/bin/ps/ps.1 (revision 7596ee73)
Copyright (c) 1980, 1990 The Regents of the University of California.
All rights reserved.

%sccs.include.redist.man%

@(#)ps.1 6.8 (Berkeley) 08/30/90

PS 1 "March 10, 1988"
C 4
NAME
ps - process status
SYNOPSIS
ps [ -ax -t tty -p pid ] [ -mr ] [ -hw ] [ -lvujs ] [ -o format ] [ -O format ] [ -mr ] [ -SC ] ps -L
DESCRIPTION
Ps prints information about processes. Normally, only your processes are candidates to be printed by ps; specifying -a causes other users' processes to be candidates to be printed; specifying -x includes processes without control terminals in the candidate pool; -t includes only processes attached to the named terminal device; and -p includes only the given process ID. The only sensible combination of these is -ax (print everything, including those without control terminals).

The default output format includes, for each process, the process's id, control terminal, cpu time (this includes both user and system time), state, and command. Alternative standard formats are available via the l , v , j , u , and s flags as described below.

By default ps attempts to limit its output per line to the width of your terminal; with the -w option, ps will use up to 132 columns, or (with -ww ) as many as necessary. With the -h option, ps will repeat the header as often as necessary to guarantee one header per ``page''. (These values are taken from the terminal's window size; see stty (1)).

Normally ps sorts its output by process ID. The -m option tells ps to sort by memory usage, while the -r option tells ps to sort by current cpu usage. The -v and -u formats imply -m and -r respectively. If more than one sort option is used, the last one given overrides the others (thus ps -um sorts by memory usage rather than %cpu). The -S and -C flags alter the calculation of process times and cpu percentage: -S (``sum'') charges all exited children to their parent processes, and -C (``cpu'') uses a ``raw'' cpu calculation that ignores ``resident'' time (usually this has no effect anyway).

Since there are so many things that can be printed (66, at last count), ps selects which process objects to print via a ``format string''. This is simply a list of names to print, separated by white space or commas. Each name can be listed at most once. The -o and -O options use the given format, and the ``standard'' output formats are simply canned strings as shown in the following table. The first entry is the default format, used only if no other format is given:

(default) pid tname state cputime comm

-l uid pid ppid cp pri nice vsize rss wchan state tname cputime comm

-v pid tt state time sl re pagein vsize rss lim tsiz trs pcpu pmem comm

-u uname pid pcpu pmem vsize rss tt state start time comm

-j user pid ppid pgid sess jobc state tname cputime comm

-s uid pid sig sigmask sigignore sigcatch stat tname comm

The -o flag adds the given string to the current format; -O adds ``pid'', then the given format, then ``state tt time command''. Effectively, -O inserts its argument into the default format after the process ID.

A complete list of names can be obtained via "ps -L" .

For backwards compatibility, the first argument need not be prefixed by a ``-''. A second argument, if any, is taken to be the file containing the system's namelist. Otherwise, /vmunix is used. A third argument, if any, tells ps where to look for a vmcore file from a crash dump. If a fourth argument is given, it is taken to be the name of a swap file to use instead of the default /dev/drum.

Some of the terms in the complete list below are defined here:

tname An abbreviation for the pathname of the controlling terminal, if any. The abbreviation consists of the two letters following ``/dev/tty'', or (for the console) ``co''. This is followed by a ``-'' if the process can no longer reach that control terminal (i.e., it has been revoked).

state The state is given by a sequence of letters, e.g., ``RWNA''. The first letter indicates the run state of the process:

0

R
marks a runnable process;
T
marks a stopped process;
P
marks a process in page wait;
D
marks a process in disk (or other short term, uninterruptable) wait;
S
marks a process that is sleeping for less than about 20 seconds;
I
marks a process that is idle (sleeping for longer than about 20 seconds);
Z
marks a dead process (a ``zombie'').
Additional characters after these, if any, indicate additional state information:

W
process is swapped out;
>
process has specified a soft limit on memory requirements and is currently exceeding that limit; such a process is (necessarily) not swapped;
N
process has reduced CPU scheduling priority (nice);
<
process has raised CPU scheduling priority;
A
process has asked for random page replacement (VA_ANOM, from vadvise (2), e.g., lisp (1) in a garbage collect);
S
process has asked for FIFO page replacement (VA_SEQL, from vadvise (2), e.g., a large image processing program using virtual memory to sequentially address voluminous data);
X
process is being traced or debugged;
E
process is working on exiting;
V
process is suspended during a vfork;
L
process has pages locked in core (e.g., for raw I/O);
s
process is a session leader;
+
process is in the foreground process group of its control terminal.

%cpu Cpu utilization of the process; this is a decaying average over up to a minute of previous (real) time. Since the time base over which this is computed varies (since processes may be very young) it is possible for the sum of all %CPU fields to exceed 100%.

nice process scheduling increment (see setpriority (2))

rss real memory (resident set) size of the process (in 1024 byte units)

lim soft limit on memory used, specified via a call to setrlimit (2)

%mem percentage of real memory used by this process.

wchan event on which process is waiting (an address in the system). When printed numerically, the initial part of the address is trimmed off and the result is printed in hex, e.g., 0x80324000 prints as 324000.

flags flags (in hex) associated with process as in < sys/proc.h >:

 SLOAD 0000001 in core
 SSYS 0000002 swapper or pager process
 SLOCK 0000004 process being swapped out
 SSWAP 0000008 save area flag
 STRC 0000010 process is being traced
 SWTED 0000020 another tracing flag
 SSINTR 0000040 sleep is interruptible
 SPAGE 0000080 process in page wait state
 SKEEP 0000100 another flag to prevent swap out
 SOMASK 0000200 restore old mask after taking signal
 SWEXIT 0000400 working on exiting
 SPHYSIO 0000800 doing physical i/o
 SVFORK 0001000 process resulted from vfork()
 SVFDONE 0002000 another vfork flag
 SNOVM 0004000 no vm, parent in a vfork()
 SPAGV 0008000 init data space on demand, from vnode
 SSEQL 0010000 user warned of sequential vm behavior
 SUANOM 0020000 user warned of random vm behavior
 STIMO 0040000 timing out during sleep
 SNOCLDSTOP 0080000 no SIGCHLD when children stop
 SCTTY 0100000 has a controlling terminal
 SOWEUPC 0200000 owe process an addupc() call at next ast
 SSEL 0400000 selecting; wakeup/waiting danger
 SEXEC 0800000 process called exec
 SHPUX 1000000 HP-UX process (HPUXCOMPAT)
 SULOCK 2000000 locked in core after swap error
 SPTECHG 4000000 pte's for process have changed

When printing a command format, a process that has exited and has a parent that has not yet waited for the process (i.e., a zombie) is marked <defunct>, and a process which is blocked trying to exit is marked <exiting>. Ps makes an educated guess as to the file name and arguments given when the process was created by examining memory or the swap area. The method is inherently somewhat unreliable and in any event a process is entitled to destroy this information, so the names cannot be counted on too much. The ucomm (accounting) name can, however, be counted on.

The following variables are available:

0

command 10
command and arguments
ucomm 10
name to be used for accounting
logname 10
login name of user who started the process
flag 10
flags (hexadecimal)
uid 10
effective user ID
ruid 10
real user ID
svuid 10
saved uid from a setuid executable
rgid 10
real group ID
svgid 10
saved gid from a setgid executable
pid 10
process ID
ppid 10
parent process ID
cp 10
short-term cpu usage factor (for scheduling)
xstat 10
exit or stop status (valid only for stopped or zombie process)
poip 10
pageouts in progress
nwchan 10
wait channel (as a number)
wchan 10
wait channel (symbolic)
rlink 10
reverse link on run queue, or 0
ktrace 10
tracing flags
ktracep 10
tracing vnode
sig 10
pending signals
sigmask 10
blocked signals
sigignore 10
ignored signals
sigcatch 10
caught signals
user 10
user name (from uid)
ruser 10
user name (from ruid)
pgid 10
process group number
jobc 10
job control count
sess 10
session pointer
tdev 10
control terminal device number
tname 10
control terminal name (two letter abbreviation)
longtname 10
full name of control terminal
tpgid 10
control terminal process group ID
tsession 10
control terminal session pointer
paddr 10
swap address
state 10
process state (symbolic)
pri 10
scheduling priority
usrpri 10
scheduling priority on return from system call
nice 10
nice
vsize 10
virtual size (Kbytes)
rssize 10
resident set size + (text size / text use count)
rss 10
resident set size
u_procp 10
process pointer
umask 10
file creation mask
acflag 10
accounting flag
start 10
time started (abbreviated)
lstart 10
time started (full)
cputime 10
accumulated cpu time (user+system)
p_ru 10
resource usage (valid only for zombie)
pcpu 10
cpu usage (percentage)
pmem 10
memory usage (percentage)
sl 10
sleep time (in seconds; 127 = infinity)
re 10
core residency time (in seconds; 127 = infinity)
pagein 10
pageins (same as majflt)
lim 10
memoryuse limit
tsiz 10
text size (in Kbytes)
trs 10
text resident set size (in Kbytes)
minflt 10
total page reclaims
majflt 10
total page faults
nswap 10
total swaps in/out
inblock 10
total blocks read
oublock 10
total blocks written
msgsnd 10
total messages sent (writes on pipes/sockets)
msgrcv 10
total messages received (reads from pipes/sockets)
nsignals 10
total signals taken
nvcsw 10
total voluntary context switches
nivcsw 10
total involuntary context switches
RUSAGE 10
short for all of the above ``totals''

FILES
/vmunix system namelist

/dev/kmem kernel memory

/dev/drum swap device

/dev searched to find swap device and tty names

/var/run/kvm_vmunix* system namelist database /var/run/devdatabase /dev name database

"SEE ALSO"
kill(1), w(1)
BUGS
Things can change while ps is running; the picture it gives is only a close approximation to reality.