Merge from vendor branch DIFFUTILS:
[dragonfly.git] / bin / ps / ps.1
1 .\" Copyright (c) 1980, 1990, 1991, 1993, 1994
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)ps.1        8.3 (Berkeley) 4/18/94
33 .\" $FreeBSD: src/bin/ps/ps.1,v 1.24.2.7 2002/06/20 22:43:33 charnier Exp $
34 .\" $DragonFly: src/bin/ps/ps.1,v 1.17 2007/05/25 00:59:06 dillon Exp $
35 .\"
36 .Dd April 6, 2006
37 .Dt PS 1
38 .Os
39 .Sh NAME
40 .Nm ps
41 .Nd process status
42 .Sh SYNOPSIS
43 .Nm
44 .Op Fl aCcefhjlmrSTuvwx
45 .Op Fl M Ar core
46 .Op Fl N Ar system
47 .Op Fl O Ar fmt
48 .Op Fl o Ar fmt
49 .Op Fl p Ar pid
50 .Op Fl t Ar tty
51 .Op Fl U Ar username
52 .Nm
53 .Op Fl L
54 .Sh DESCRIPTION
55 The
56 .Nm
57 utility
58 displays a header line followed by lines containing information about your
59 processes that have controlling terminals.
60 This information is sorted by controlling terminal, then by process ID.
61 .Pp
62 The information displayed is selected based on a set of keywords (see the
63 .Fl L
64 .Fl O
65 and
66 .Fl o
67 options).
68 The default output format includes, for each process, the process' ID,
69 controlling terminal, CPU time (including both user and system time),
70 state, and associated command.
71 .Pp
72 The process file system (see
73 .Xr procfs 5 )
74 should be mounted when
75 .Nm
76 is executed, otherwise not all information will be available.
77 .Pp
78 The options are as follows:
79 .Bl -tag -width indent
80 .It Fl a
81 Display information about other users' processes as well as your own.
82 This can be disabled by setting the
83 .Va kern.ps_showallprocs
84 sysctl to zero.
85 .It Fl c
86 Change the ``command'' column output to just contain the executable name,
87 rather than the full command line.
88 .It Fl C
89 Change the way the CPU percentage is calculated by using a ``raw''
90 CPU calculation that ignores ``resident'' time (this normally has
91 no effect).
92 .It Fl e
93 Display the environment as well.
94 .It Fl f
95 Show commandline and environment information about swapped out processes.
96 This option is honored only if the uid of the user is 0.
97 .It Fl h
98 Repeat the information header as often as necessary to guarantee one
99 header per page of information.
100 .It Fl j
101 Print information associated with the following keywords:
102 .Cm user , pid , ppid , pgid , sess , jobc , state , tt , time ,
103 and
104 .Cm command .
105 .It Fl L
106 List the set of available keywords.
107 .It Fl l
108 Display information associated with the following keywords:
109 .Cm uid , pid , ppid , cpu , pri , nice , vsz , rss , wchan , state ,
110 .Cm tt , time ,
111 and
112 .Cm command .
113 .It Fl M
114 Extract values associated with the name list from the specified core
115 instead of the default
116 .Pa /dev/kmem .
117 .It Fl m
118 Sort by memory usage, instead of by process ID.
119 .It Fl N
120 Extract the name list from the specified system instead of the default
121 .Pa /kernel .
122 .It Fl O
123 Add the information associated with the space or comma separated list
124 of keywords specified, after the process ID,
125 in the default information
126 display.
127 Keywords may be appended with an equals (``='') sign and a string.
128 This causes the printed header to use the specified string instead of
129 the standard header.
130 .It Fl o
131 Display information associated with the space or comma separated list
132 of keywords specified.
133 Keywords may be appended with an equals (``='') sign and a string.
134 This causes the printed header to use the specified string instead of
135 the standard header.
136 .It Fl p
137 Display information associated with the specified process ID.
138 .It Fl r
139 Sort by current CPU usage, instead of by process ID.
140 .It Fl S
141 Change the way the process time is calculated by summing all exited
142 children to their parent process.
143 .It Fl T
144 Display information about processes attached to the device associated
145 with the standard input.
146 .It Fl t
147 Display information about processes attached to the specified terminal
148 device.
149 .It Fl U
150 Display the processes belonging to the specified
151 .Ar username .
152 .It Fl u
153 Display information associated with the following keywords:
154 .Cm user , pid, %cpu , %mem , vsz , rss , tt , state , start , time ,
155 and
156 .Cm command .
157 The
158 .Fl u
159 option implies the
160 .Fl r
161 option.
162 .It Fl v
163 Display information associated with the following keywords:
164 .Cm pid , state , time , sl , re , pagein , vsz , rss , lim , tsiz ,
165 .Cm %cpu , %mem
166 and
167 .Cm command .
168 The
169 .Fl v
170 option implies the
171 .Fl m
172 option.
173 .It Fl w
174 Use 132 columns to display information, instead of the default which
175 is your window size.
176 If the
177 .Fl w
178 option is specified more than once,
179 .Nm
180 will use as many columns as necessary without regard for your window size.
181 .It Fl x
182 Display information about processes without controlling terminals.
183 .El
184 .Pp
185 A complete list of the available keywords are listed below.
186 Some of these keywords are further specified as follows:
187 .Bl -tag -width ".Cm lstart"
188 .It Cm %cpu
189 The CPU utilization of the process; this is a decaying average over up to
190 a minute of previous (real) time.
191 Since the time base over which this is computed varies (since processes may
192 be very young) it is possible for the sum of all
193 .Cm %cpu
194 fields to exceed 100%.
195 .It Cm %mem
196 The percentage of real memory used by this process.
197 .It Cm flags
198 The flags associated with the process as in
199 the include file
200 .In sys/proc.h .
201 .It Cm lim
202 The soft limit on memory used, specified via a call to
203 .Xr setrlimit 2 .
204 .It Cm lstart
205 The exact time the command started, using the ``%c'' format described in
206 .Xr strftime 3 .
207 .It Cm nice
208 The process scheduling increment (see
209 .Xr setpriority 2 ) .
210 .It Cm rss
211 the real memory (resident set) size of the process (in 1024 byte units).
212 .It Cm start
213 The time the command started.
214 If the command started less than 24 hours ago, the start time is
215 displayed using the ``%l:ps.1p'' format described in
216 .Xr strftime 3 .
217 If the command started less than 7 days ago, the start time is
218 displayed using the ``%a6.15p'' format.
219 Otherwise, the start time is displayed using the ``%e%b%y'' format.
220 .It Cm state
221 The state is given by a sequence of letters, for example,
222 .Dq Li RWNA .
223 The first letter indicates the run state of the process:
224 .Pp
225 .Bl -tag -width indent -compact
226 .It Li B
227 Marks a blocked kernel thread.
228 .It Li D
229 Marks a process in disk (or other short term, uninterruptible) wait.
230 .It Li I
231 Marks a process that is idle (sleeping for longer than about 20 seconds).
232 .It Li J
233 Marks a process which is in
234 .Xr jail 2 .
235 The hostname of the prison can be found in
236 .Pa /proc/ Ns Ao Ar pid Ac Ns Pa /status .
237 .It Li R
238 Marks a runnable process and is followed by the CPU number.
239 .It Li S
240 Marks a process that is sleeping for less than about 20 seconds.
241 .It Li T
242 Marks a stopped process.
243 .It Li Z
244 Marks a dead process (a
245 .Dq zombie ) .
246 .El
247 .Pp
248 Additional characters after these, if any, indicate additional state
249 information:
250 .Pp
251 .Bl -tag -width indent -compact
252 .It Li +
253 The process is in the foreground process group of its control terminal.
254 .It Li <
255 The process has raised CPU scheduling priority.
256 .It Li >
257 The process has specified a soft limit on memory requirements and is
258 currently exceeding that limit; such a process is (necessarily) not
259 swapped.
260 .It Li A
261 the process has asked for random page replacement
262 .Pf ( Dv MADV_RANDOM ,
263 from
264 .Xr madvise 2 ,
265 for example,
266 .Xr lisp 1
267 in a garbage collect).
268 .It Li E
269 The process is trying to exit.
270 .It Li L
271 The process has pages locked in core (for example, for raw
272 .Tn I/O ) .
273 .It Li M
274 On SMP systems indicates a process or thread which is
275 .Em not
276 holding the MP lock (the Big Giant Lock).
277 .It Li N
278 The process has reduced CPU scheduling priority (see
279 .Xr setpriority 2 ) .
280 .It Li S
281 The process has asked for FIFO page replacement
282 .Pf ( Dv MADV_SEQUENTIAL ,
283 from
284 .Xr madvise 2 ,
285 for example, a large image processing program using virtual memory to
286 sequentially address voluminous data).
287 .It Li s
288 The process is a session leader.
289 .It Li V
290 The process is suspended during a
291 .Xr vfork 2 .
292 .It Li W
293 The process is swapped out.
294 .It Li X
295 The process is being traced or debugged.
296 .El
297 .It Cm tt
298 An abbreviation for the pathname of the controlling terminal, if any.
299 The abbreviation consists of the three letters following
300 .Pa /dev/tty ,
301 or, for the console, ``con''.
302 This is followed by a ``-'' if the process can no longer reach that
303 controlling terminal (i.e., it has been revoked).
304 .It Cm wchan
305 The event (an address in the system) on which a process waits.
306 When printed numerically, the initial part of the address is
307 trimmed off and the result is printed in hex, for example, 0x80324000 prints
308 as 324000.  Note that blocked threads often only have ascii wchan's.
309 .El
310 .Pp
311 When printing using the
312 .Cm command
313 keyword, a process that has exited and
314 has a parent that has not yet waited for the process (in other words, a zombie)
315 is listed as ``<defunct>'', and a process which is blocked while trying
316 to exit is listed as ``<exiting>''.
317 The
318 .Nm
319 utility
320 makes an educated guess as to the file name and arguments given when the
321 process was created by examining memory or the swap area.
322 The method is inherently somewhat unreliable and in any event a process
323 is entitled to destroy this information, so the names cannot be depended
324 on too much.
325 The
326 .Cm ucomm
327 (accounting) keyword can, however, be depended on.
328 .Sh KEYWORDS
329 The following is a complete list of the available keywords and their
330 meanings.
331 Several of them have aliases (keywords which are synonyms).
332 .Pp
333 .Bl -tag -width ".Cm sigignore" -compact
334 .It Cm %cpu
335 percentage CPU usage (alias
336 .Cm pcpu )
337 .It Cm %mem
338 percentage memory usage (alias
339 .Cm pmem )
340 .It Cm acflag
341 accounting flag (alias
342 .Cm acflg )
343 .It Cm batch
344 batchness of the process (higher numbers mean less interactivity)
345 .It Cm command
346 command and arguments
347 .It Cm cpu
348 short-term CPU usage factor (for scheduling)
349 .It Cm f
350 the process flags, in hexadecimal (alias
351 .Cm flags )
352 .It Cm inblk
353 total blocks read (alias
354 .Cm inblock )
355 .It Cm jail
356 jail ID
357 .It Cm jobc
358 job control count
359 .It Cm ktrace
360 tracing flags
361 .\" .It Cm ktracep
362 .\" tracing vnode
363 .It Cm lastcpu
364 CPU ID the process was last scheduled on
365 .It Cm lim
366 memoryuse limit
367 .It Cm login
368 login name of user who started the process (alias
369 .Cm logname )
370 .It Cm lstart
371 time started
372 .It Cm majflt
373 total page faults
374 .It Cm minflt
375 total page reclaims
376 .It Cm msgrcv
377 total messages received (reads from pipes/sockets)
378 .It Cm msgsnd
379 total messages sent (writes on pipes/sockets)
380 .It Cm nice
381 nice value (alias
382 .Cm ni )
383 .It Cm nivcsw
384 total involuntary context switches
385 .It Cm nsigs
386 total signals taken (alias
387 .Cm nsignals )
388 .It Cm nswap
389 total swaps in/out
390 .It Cm nvcsw
391 total voluntary context switches
392 .It Cm nwchan
393 wait channel (as an address)
394 .It Cm oublk
395 total blocks written (alias
396 .Cm oublock )
397 .It Cm p_ru
398 resource usage (valid only for zombie)
399 .It Cm paddr
400 swap address
401 .It Cm pagein
402 pageins (same as
403 .Cm majflt )
404 .It Cm pgid
405 process group number
406 .It Cm pid
407 process ID
408 .It Cm ppid
409 parent process ID
410 .It Cm pri
411 scheduling priority (lower == better)
412 .It Cm re
413 core residency time (in seconds; 127 = infinity)
414 .It Cm rgid
415 real group ID
416 .\" .It Cm rlink
417 .\" reverse link on run queue, or 0
418 .It Cm rss
419 resident set size
420 .It Cm rsz
421 resident set size + (text size / text use count) (alias
422 .Cm rssize )
423 .It Cm rtprio
424 realtime priority (101 = not a realtime process)
425 .It Cm ruid
426 real user ID
427 .It Cm ruser
428 user name (from ruid)
429 .It Cm sess
430 session pointer
431 .It Cm sig
432 pending signals (alias
433 .Cm pending )
434 .It Cm sigcatch
435 caught signals (alias
436 .Cm caught )
437 .It Cm sigignore
438 ignored signals (alias
439 .Cm ignored )
440 .It Cm sigmask
441 blocked signals (alias
442 .Cm blocked )
443 .It Cm sl
444 sleep time (in seconds; 127 = infinity)
445 .It Cm start
446 time started
447 .It Cm state
448 symbolic process state (alias
449 .Cm stat )
450 .It Cm svgid
451 saved gid from a setgid executable
452 .It Cm svuid
453 saved uid from a setuid executable
454 .It Cm tdev
455 control terminal device number
456 .It Cm tdpri
457 LWKT thread priority (0-31, 31 highest), and critical section count
458 .It Cm time
459 accumulated CPU time, user + system (alias
460 .Cm cputime )
461 .It Cm tpgid
462 control terminal process group ID
463 .\".It Cm trss
464 .\"text resident set size (in Kbytes)
465 .It Cm tsess
466 control terminal session pointer
467 .It Cm tsig
468 pending thread signals
469 .It Cm tsiz
470 text size (in Kbytes)
471 .It Cm tt
472 control terminal name (two letter abbreviation)
473 .It Cm tty
474 full name of control terminal
475 .It Cm ucomm
476 name to be used for accounting
477 .It Cm uid
478 effective user ID
479 .It Cm user
480 user name (from uid)
481 .It Cm vsz
482 virtual size in Kbytes (alias
483 .Cm vsize )
484 .It Cm wchan
485 wait channel (as a symbolic name)
486 .It Cm xstat
487 exit or stop status (valid only for stopped or zombie process)
488 .El
489 .Sh FILES
490 .Bl -tag -width /var/db/kvm_kernel.db -compact
491 .It Pa /dev/kmem
492 default kernel memory
493 .It Pa /var/run/dev.db
494 /dev name database
495 .It Pa /var/db/kvm_kernel.db
496 system namelist database
497 .It Pa /kernel
498 default system namelist
499 .It Pa /proc
500 the mount point of
501 .Xr procfs 5
502 .El
503 .Sh SEE ALSO
504 .Xr kill 1 ,
505 .Xr w 1 ,
506 .Xr kvm 3 ,
507 .Xr strftime 3 ,
508 .Xr procfs 5 ,
509 .Xr pstat 8 ,
510 .Xr sysctl 8
511 .Sh HISTORY
512 The
513 .Nm
514 command appeared in
515 .At v4 .
516 .Sh BUGS
517 Since
518 .Nm
519 cannot run faster than the system and is run as any other scheduled
520 process, the information it displays can never be exact.