1.\"	$OpenBSD: ps.1,v 1.53 2005/07/01 05:21:20 jmc Exp $
2.\"	$NetBSD: ps.1,v 1.16 1996/03/21 01:36:28 jtc Exp $
3.\"
4.\" Copyright (c) 1980, 1990, 1991, 1993, 1994
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"     @(#)ps.1	8.3 (Berkeley) 4/18/94
32.\"
33.Dd April 18, 1994
34.Dt PS 1
35.Os
36.Sh NAME
37.Nm ps
38.Nd process status
39.Sh SYNOPSIS
40.Nm ps
41.Sm off
42.Oo \&- Oc Op Cm aCcehjklmrSTuvwx
43.Sm on
44.Op Fl M Ar core
45.Op Fl N Ar system
46.Op Fl O Ar fmt
47.Op Fl o Ar fmt
48.Op Fl p Ar pid
49.Op Fl t Ar tty
50.Op Fl U Ar username
51.Op Fl W Ar swap
52.Nm ps
53.Op Fl L
54.Sh DESCRIPTION
55The
56.Nm
57utility displays information about active processes.
58When given no options,
59.Nm
60prints information about processes associated with the controlling terminal.
61.Pp
62The information displayed is selected based on a set of keywords (and for
63even more control, see the
64.Fl L ,
65.Fl O ,
66and
67.Fl o
68options).
69The default output format includes, for each process, the process's ID,
70controlling terminal, CPU time (including both user and system time),
71state, and associated command.
72.Pp
73The options are as follows:
74.Bl -tag -width Ds
75.It Fl a
76Display information about other users' processes as well as your own.
77.It Fl C
78Change the way the CPU percentage is calculated by using a
79.Dq raw
80CPU calculation that ignores
81.Dq resident
82time (this normally has
83no effect).
84.It Fl c
85Do not display full command with arguments, but only the
86executable name.
87This may be somewhat confusing; for example, all
88.Xr sh 1
89scripts will show as
90.Dq sh .
91.It Fl e
92Display the environment as well.
93.It Fl h
94Repeat the information header as often as necessary to guarantee one
95header per page of information.
96.It Fl j
97Print information associated with the following keywords:
98user, pid, ppid, pgid, sess, jobc, state, tt, time, and command.
99.It Fl k
100Also display information about kernel threads.
101.It Fl L
102List the set of available keywords.
103.It Fl l
104Display information associated with the following keywords:
105uid, pid, ppid, cpu, pri, nice, vsz, rss, wchan, state, tt, time
106and command.
107.It Fl M Ar core
108Extract values associated with the name list from the specified core
109instead of the running kernel.
110.It Fl m
111Sort by memory usage, instead of by start time
112.Tn ID .
113.It Fl N Ar system
114Extract the name list from the specified system instead of the running kernel.
115.It Fl O Ar fmt
116Add the information associated with the space or comma separated list
117of keywords specified, after the process
118.Tn ID ,
119in the default information
120display.
121Keywords may be appended with an equals sign
122.Pq Sq =
123and a string.
124This causes the printed header to use the specified string instead of
125the standard header.
126.It Fl o Ar fmt
127Display information associated with the space or comma separated list
128of keywords specified.
129Keywords may be appended with an equals sign
130.Pq Sq =
131and a string.
132This causes the printed header to use the specified string instead of
133the standard header.
134.It Fl p Ar pid
135Display information associated with the specified process
136.Tn ID .
137.It Fl r
138Sort by current CPU usage, instead of by start time
139.Tn ID .
140.It Fl S
141Change the way the process time is calculated by summing all exited
142children to their parent process.
143.It Fl T
144Display information about processes attached to the device associated
145with the standard input.
146.It Fl t Ar tty
147Display information about processes attached to the specified terminal
148device.
149.It Fl U Ar username
150Display the processes belonging to the specified
151.Ar username .
152.It Fl u
153Display information associated with the following keywords:
154user, pid, %cpu, %mem, vsz, rss, tt, state, start, time, and command.
155The
156.Fl u
157option implies the
158.Fl r
159option.
160.It Fl v
161Display information associated with the following keywords:
162pid, state, time, sl, re, pagein, vsz, rss, lim, tsiz,
163%cpu, %mem and command.
164The
165.Fl v
166option implies the
167.Fl m
168option.
169.It Fl W Ar swap
170Extract swap information from the specified file instead of the
171default
172.Dq Pa /dev/drum .
173.It Fl w
174Use 132 columns to display information, instead of the default, which
175is your window size.
176If the
177.Fl w
178option is specified more than once,
179.Nm
180will use as many columns as necessary without regard for your window size.
181.It Fl x
182Display information about processes without controlling terminals.
183.El
184.Pp
185All available keywords are listed below.
186Some of these keywords are further specified as follows:
187.Bl -tag -width indent
188.It %cpu
189The CPU utilization of the process; this is a decaying average over up to
190a minute of previous (real) time.
191Since the time base over which this is computed varies (since processes may
192be very young) it is possible for the sum of all
193.Tn \&%cpu
194fields to exceed 100%.
195.It %mem
196The percentage of real memory used by this process.
197.It flags
198The flags (in hexadecimal) associated with the process as in
199the include file
200.Aq Pa sys/proc.h :
201.Bl -column P_NOCLDSTOP P_NOCLDSTOP
202.It Dv "P_ADVLOCK" Ta No "0x0000001	process may hold a POSIX advisory lock"
203.It Dv "P_CONTROLT" Ta No "0x0000002	process has a controlling terminal"
204.It Dv "P_INMEM" Ta No "0x0000004	process is loaded into memory"
205.It Dv "P_NOCLDSTOP" Ta No "0x0000008	no
206.Dv SIGCHLD
207when children stop
208.It Dv "P_PPWAIT" Ta No "0x0000010	parent is waiting for child to exec/exit"
209.It Dv "P_PROFIL" Ta No "0x0000020	process has started profiling"
210.It Dv "P_SELECT" Ta No "0x0000040	selecting; wakeup/waiting danger"
211.It Dv "P_SINTR" Ta No "0x0000080	sleep is interruptible"
212.It Dv "P_SUGID" Ta No "0x0000100	process had set id privileges since last exec"
213.It Dv "P_SYSTEM" Ta No "0x0000200	system process: no sigs, stats or swapping"
214.It Dv "P_TIMEOUT" Ta No "0x0000400	timing out during sleep"
215.It Dv "P_TRACED" Ta No "0x0000800	process is being traced"
216.It Dv "P_WAITED" Ta No "0x0001000	debugging process has waited for child"
217.It Dv "P_WEXIT" Ta No "0x0002000	working on exiting"
218.It Dv "P_EXEC" Ta No "0x0004000	process called"
219.Xr exec 3
220.It Dv "P_OWEUPC" Ta No "0x0008000	owe process an addupc() call at next ast"
221.\" the routine addupc is not documented in the man pages
222.It Dv "P_FSTRACE" Ta No "0x0010000	tracing via file system"
223.It Dv "P_SSTEP" Ta No "0x0020000	process needs single-step fixup"
224.It Dv "P_SUGIDEXEC" Ta No "0x0040000	last
225.Xr exec 3
226was set[ug]id
227.It Dv "P_NOCLDWAIT" Ta No "0x0080000	let pid 1 wait for my children"
228.It Dv "P_NOZOMBIE" Ta No "0x0100000	pid 1 waits for me instead of dad"
229.It Dv "P_INEXEC" Ta No "0x0200000	process is doing an exec right now"
230.It Dv "P_SYSTRACE" Ta No "0x0400000	process system call tracing is active"
231.El
232.It lim
233The soft limit on memory used, specified via a call to
234.Xr setrlimit 2 .
235.It lstart
236The exact time the command started, using the
237.Dq %c
238format described in
239.Xr strftime 3 .
240.It nice
241The process scheduling increment (see
242.Xr setpriority 2 ) .
243.It rss
244The real memory (resident set) size of the process (in 1024 byte units).
245.It start
246The time the command started.
247If the command started less than 24 hours ago, the start time is
248displayed using the
249.Dq %l:%M%p
250format described in
251.Xr strftime 3 .
252If the command started less than 7 days ago, the start time is
253displayed using the
254.Dq %a%I%p
255format.
256Otherwise, the start time is displayed using the
257.Dq %e%b%y
258format.
259.It state
260The state is given by a sequence of letters, for example,
261.Dq Tn RWN .
262The first letter indicates the run state of the process:
263.Pp
264.Bl -tag -width indent -compact
265.It D
266Marks a process in disk (or other short term, uninterruptible) wait.
267.It I
268Marks a process that is idle (sleeping for longer than about 20 seconds).
269.It R
270Marks a runnable process.
271.It S
272Marks a process that is sleeping for less than about 20 seconds.
273.It T
274Marks a stopped process.
275.It Z
276Marks a dead process (a
277.Dq zombie ) .
278.El
279.Pp
280Additional characters after these, if any, indicate additional state
281information:
282.Pp
283.Bl -tag -width indent -compact
284.It +
285The process is in the foreground process group of its control terminal.
286.It \*(Lt
287The process has raised
288.Tn CPU
289scheduling priority.
290.It \*(Gt
291The process has specified a soft limit on memory requirements and is
292currently exceeding that limit; such a process is (necessarily) not
293swapped.
294.\" .It A
295.\" the process has asked for random page replacement
296.\" .Pf ( Dv MADV_RANDOM ,
297.\" from
298.\" .Xr madvise 2 ,
299.\" for example,
300.\" .Xr lisp 1
301.\" in a garbage collect).
302.It E
303The process is trying to exit.
304.It K
305The process is a kernel thread.
306.It L
307The process has pages locked in core (for example, for raw
308.Tn I/O ) .
309.It N
310The process has reduced
311.Tn CPU
312scheduling priority (see
313.Xr setpriority 2 ) .
314.\" .It S
315.\" The process has asked for
316.\" .Tn FIFO
317.\" page replacement
318.\" .Pf ( Dv MADV_SEQUENTIAL ,
319.\" from
320.\" .Xr madvise 2 ,
321.\" for example, a large image processing program using virtual memory to
322.\" sequentially address voluminous data).
323.It s
324The process is a session leader.
325.It V
326The process is suspended during a
327.Xr vfork 2 .
328.It W
329The process is swapped out.
330.It X
331The process is being traced or debugged.
332.It x
333The process is being monitored by
334.Xr systrace 1 .
335.It / Ns Ar n
336On multiprocessor machines, specifies processor number
337.Ar n .
338.El
339.It tt
340An abbreviation for the pathname of the controlling terminal, if any.
341The abbreviation consists of the two letters following
342.Dq Pa /dev/tty ,
343or, for the console,
344.Dq co .
345This is followed by a
346.Dq \-
347if the process can no longer reach that
348controlling terminal (i.e., it has been revoked).
349.It wchan
350The event (an address in the system) on which a process waits.
351When printed numerically, the initial part of the address is
352trimmed off and the result is printed in hex; for example, 0x80324000 prints
353as 324000.
354.El
355.Pp
356When printing using the command keyword, a process that has exited and
357has a parent that has not yet waited for the process (in other words, a zombie)
358is listed as
359.Dq Aq defunct ,
360and a process which is blocked while trying
361to exit is listed as
362.Dq Aq exiting .
363.Nm
364makes an educated guess as to the file name and arguments given when the
365process was created by examining memory or the swap area.
366The method is inherently somewhat unreliable and in any event a process
367is entitled to destroy this information, so the names cannot be depended
368on too much.
369The ucomm (accounting) keyword can, however, be depended on.
370.Sh KEYWORDS
371The following is a complete list of the available keywords and their
372meanings.
373Several of them have aliases (keywords which are synonyms).
374.Pp
375.Bl -tag -width sigignore -compact
376.It %cpu
377percentage CPU usage (alias pcpu)
378.It %mem
379percentage memory usage (alias pmem)
380.It acflag
381accounting flag (alias acflg)
382.It command
383command and arguments (alias args)
384.It cpu
385short-term CPU usage factor (for scheduling)
386.It cpuid
387CPU ID (zero on single processor systems)
388.It dsiz
389data size (in Kbytes)
390.It emul
391name of system call emulation environment
392.It flags
393the process flags, in hexadecimal (alias f)
394.It gid
395effective group
396.It group
397text name of effective group
398.Tn ID
399.It holdcnt
400number of holds on the process (if non-zero, process can't be swapped)
401.It inblk
402total blocks read (alias inblock)
403.It jobc
404job control count
405.It ktrace
406tracing flags
407.It ktracep
408tracing vnode
409.It lim
410memory usage limit
411.It logname
412login name of user who started the process
413(alias login)
414.It lstart
415time started
416.It majflt
417total page faults
418.It minflt
419total page reclaims
420.It msgrcv
421total messages received (reads from pipes/sockets)
422.It msgsnd
423total messages sent (writes on pipes/sockets)
424.It nice
425nice value (alias ni)
426.It nivcsw
427total involuntary context switches
428.It nsigs
429total signals taken (alias nsignals)
430.It nswap
431total swaps in/out
432.It nvcsw
433total voluntary context switches
434.It nwchan
435wait channel (as an address)
436.It oublk
437total blocks written (alias oublock)
438.It p_ru
439resource usage (valid only for zombie)
440.It paddr
441swap address
442.It pagein
443pageins (same as majflt)
444.It pgid
445process group number
446.It pid
447process
448.Tn ID
449.It ppid
450parent process
451.Tn ID
452.It pri
453scheduling priority
454.It re
455core residency time (in seconds; 127 = infinity)
456.It rgid
457real group
458.Tn ID
459.It rgroup
460text name of real group
461.Tn ID
462.It rlink
463reverse link on run queue, or 0
464.It rss
465resident set size
466.It rsz
467resident set size + (text size / text use count) (alias rssize)
468.It ruid
469real user
470.Tn ID
471.It ruser
472user name (from ruid)
473.It sess
474session pointer
475.It sig
476pending signals (alias pending)
477.It sigcatch
478caught signals (alias caught)
479.It sigignore
480ignored signals (alias ignored)
481.It sigmask
482blocked signals (alias blocked)
483.It sl
484sleep time (in seconds; 127 = infinity)
485.It ssiz
486stack size (in Kbytes)
487.It start
488time started (alias etime)
489.It state
490symbolic process state (alias stat)
491.It svgid
492saved GID from a setgid executable
493.It svuid
494saved UID from a setuid executable
495.It tdev
496control terminal device number
497.It time
498accumulated CPU time, user + system (alias cputime)
499.It tpgid
500control terminal process group
501.Tn ID
502.\".It trss
503.\"text resident set size (in Kbytes)
504.It tsess
505control terminal session pointer
506.It tsiz
507text size (in Kbytes)
508.It tt
509control terminal name (two letter abbreviation)
510.It tty
511full name of control terminal
512.It ucomm
513name to be used for accounting (alias comm)
514.It uid
515effective user
516.Tn ID
517.It upr
518scheduling priority on return from system call (alias usrpri)
519.It user
520user name (from uid)
521.It vsz
522virtual size in Kbytes (alias vsize)
523.It wchan
524wait channel (as a symbolic name)
525.It xstat
526exit or stop status (valid only for stopped or zombie process)
527.El
528.Sh FILES
529.Bl -tag -width /var/db/kvm_bsd.db -compact
530.It Pa /dev
531special files and device names
532.It Pa /dev/drum
533default swap device
534.It Pa /var/run/dev.db
535/dev name database
536.It Pa /var/db/kvm_bsd.db
537system namelist database
538.El
539.Sh EXAMPLES
540Display information on all system processes:
541.Pp
542.Dl $ ps -auxw
543.Sh SEE ALSO
544.Xr fstat 1 ,
545.Xr kill 1 ,
546.Xr pgrep 1 ,
547.Xr pkill 1 ,
548.Xr procmap 1 ,
549.Xr sh 1 ,
550.Xr top 1 ,
551.Xr w 1 ,
552.Xr kvm 3 ,
553.Xr strftime 3 ,
554.Xr dev_mkdb 8 ,
555.Xr pstat 8
556.Sh HISTORY
557A
558.Nm
559command appeared in
560.At v3
561in section 8 of the manual.
562.Sh BUGS
563Since
564.Nm
565cannot run faster than the system and is run as any other scheduled
566process, the information it displays can never be exact.
567