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