All rights reserved.
%sccs.include.redist.man%
@(#)ps.1 6.8 (Berkeley) 08/30/90
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
%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
/dev searched to find swap device and tty names
/var/run/kvm_vmunix* system namelist database /var/run/devdatabase /dev name database