Merge from vendor branch BINUTILS:
[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.10 2006/04/07 09:57:37 swildner 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 aCcefhjlmrSTuvwxyY
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 .It Fl y
184 Display information associated with the following keywords:
185 .Cm uid , pid , ppid , cpu , pri , iac , nice , wchan , state , tt , time ,
186 and
187 .Cm command .
188 Sort by iac (interactivity measure).
189 .It Fl Y
190 Sort by iac (interactivity measure).
191 .El
192 .Pp
193 A complete list of the available keywords are listed below.
194 Some of these keywords are further specified as follows:
195 .Bl -tag -width ".Cm lstart"
196 .It Cm %cpu
197 The CPU utilization of the process; this is a decaying average over up to
198 a minute of previous (real) time.
199 Since the time base over which this is computed varies (since processes may
200 be very young) it is possible for the sum of all
201 .Cm %cpu
202 fields to exceed 100%.
203 .It Cm %mem
204 The percentage of real memory used by this process.
205 .It Cm flags
206 The flags associated with the process as in
207 the include file
208 .In sys/proc.h :
209 .Bl -column P_BREAKTSLEEP 0x10000000
210 .It Dv "P_ADVLOCK" Ta No "0x00001       Process may hold a POSIX advisory lock"
211 .It Dv "P_CONTROLT" Ta No "0x00002      Has a controlling terminal"
212 .It Dv "P_SWAPPEDOUT" Ta No "0x00004    Swapped out of memory"
213 .It Dv "P_BREAKTSLEEP" Ta No "0x00008   Event pending, break tsleep on sigcont"
214 .It Dv "P_PPWAIT" Ta No "0x00010        Parent is waiting for child to exec/exit"
215 .It Dv "P_PROFIL" Ta No "0x00020        Has started profiling"
216 .It Dv "P_SELECT" Ta No "0x00040        Selecting; wakeup/waiting danger"
217 .It Dv "P_SINTR" Ta No "0x00080         Sleep is interruptible"
218 .It Dv "P_SUGID" Ta No "0x00100         Had set id privileges since last exec"
219 .It Dv "P_SYSTEM" Ta No "0x00200        System proc: no sigs, stats or swapping"
220 .It Dv "P_STOPPED" Ta No "0x00400       SIGSTOP status"
221 .It Dv "P_TRACED" Ta No "0x00800        Debugged process being traced"
222 .It Dv "P_WAITED" Ta No "0x01000        SIGSTOP status was returned by wait3/4"
223 .It Dv "P_WEXIT" Ta No "0x02000         Working on exiting"
224 .It Dv "P_EXEC" Ta No "0x04000          Process called exec"
225 .It Dv "P_UPCALLPEND" Ta No "0x20000    An upcall is pending"
226 .It Dv "P_SWAPWAIT" Ta No "0x40000      Waiting for a swapin"
227 .It Dv "P_ZOMBIE" Ta No "0x80000        Now in a zombied state"
228 .It Dv "P_ONRUNQ" Ta No "0x100000       On a user scheduling run queue"
229 .It Dv "P_KTHREADP" Ta No "0x200000     Process is really a kernel thread"
230 .It Dv "P_IDLESWAP" Ta No "0x400000     Swapout was due to idleswap, not load"
231 .It Dv "P_DEADLKTREAT" Ta No "0x800000  Lock aquisition - deadlock treatment"
232 .It Dv "P_JAILED" Ta No "0x1000000      Process is in jail"
233 .It Dv "P_OLDMASK" Ta No "0x2000000     Need to restore mask before pause"
234 .It Dv "P_ALTSTACK" Ta No "0x4000000    have alternate signal stack"
235 .It Dv "P_INEXEC" Ta No "0x8000000      Process is in execve()"
236 .It Dv "P_PASSIVE_ACQ" Ta No "0x10000000        Passive acquire cpu (see kern_switch)"
237 .It Dv "P_UPCALLWAIT" Ta No "0x20000000 Wait for upcall or signal"
238 .El
239 .It Cm lim
240 The soft limit on memory used, specified via a call to
241 .Xr setrlimit 2 .
242 .It Cm lstart
243 The exact time the command started, using the ``%c'' format described in
244 .Xr strftime 3 .
245 .It Cm nice
246 The process scheduling increment (see
247 .Xr setpriority 2 ) .
248 .It Cm rss
249 the real memory (resident set) size of the process (in 1024 byte units).
250 .It Cm start
251 The time the command started.
252 If the command started less than 24 hours ago, the start time is
253 displayed using the ``%l:ps.1p'' format described in
254 .Xr strftime 3 .
255 If the command started less than 7 days ago, the start time is
256 displayed using the ``%a6.15p'' format.
257 Otherwise, the start time is displayed using the ``%e%b%y'' format.
258 .It Cm state
259 The state is given by a sequence of letters, for example,
260 .Dq Li RWNA .
261 The first letter indicates the run state of the process:
262 .Pp
263 .Bl -tag -width indent -compact
264 .It Li D
265 Marks a process in disk (or other short term, uninterruptible) wait.
266 .It Li I
267 Marks a process that is idle (sleeping for longer than about 20 seconds).
268 .It Li J
269 Marks a process which is in
270 .Xr jail 2 .
271 The hostname of the prison can be found in
272 .Pa /proc/ Ns Ao Ar pid Ac Ns Pa /status .
273 .It Li R
274 Marks a runnable process.
275 .It Li S
276 Marks a process that is sleeping for less than about 20 seconds.
277 .It Li T
278 Marks a stopped process.
279 .It Li Z
280 Marks a dead process (a
281 .Dq zombie ) .
282 .El
283 .Pp
284 Additional characters after these, if any, indicate additional state
285 information:
286 .Pp
287 .Bl -tag -width indent -compact
288 .It Li +
289 The process is in the foreground process group of its control terminal.
290 .It Li <
291 The process has raised CPU scheduling priority.
292 .It Li >
293 The process has specified a soft limit on memory requirements and is
294 currently exceeding that limit; such a process is (necessarily) not
295 swapped.
296 .It Li A
297 the process has asked for random page replacement
298 .Pf ( Dv MADV_RANDOM ,
299 from
300 .Xr madvise 2 ,
301 for example,
302 .Xr lisp 1
303 in a garbage collect).
304 .It Li E
305 The process is trying to exit.
306 .It Li L
307 The process has pages locked in core (for example, for raw
308 .Tn I/O ) .
309 .It Li M
310 On SMP systems indicates a process or thread which is
311 .Em not
312 holding the MP lock (the Big Giant Lock).
313 .It Li N
314 The process has reduced CPU scheduling priority (see
315 .Xr setpriority 2 ) .
316 .It Li S
317 The process has asked for FIFO 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 Li s
324 The process is a session leader.
325 .It Li V
326 The process is suspended during a
327 .Xr vfork .
328 .It Li W
329 The process is swapped out.
330 .It Li X
331 The process is being traced or debugged.
332 .El
333 .It Cm tt
334 An abbreviation for the pathname of the controlling terminal, if any.
335 The abbreviation consists of the three letters following
336 .Pa /dev/tty ,
337 or, for the console, ``con''.
338 This is followed by a ``-'' if the process can no longer reach that
339 controlling terminal (i.e., it has been revoked).
340 .It Cm wchan
341 The event (an address in the system) on which a process waits.
342 When printed numerically, the initial part of the address is
343 trimmed off and the result is printed in hex, for example, 0x80324000 prints
344 as 324000.
345 .El
346 .Pp
347 When printing using the
348 .Cm command
349 keyword, a process that has exited and
350 has a parent that has not yet waited for the process (in other words, a zombie)
351 is listed as ``<defunct>'', and a process which is blocked while trying
352 to exit is listed as ``<exiting>''.
353 The
354 .Nm
355 utility
356 makes an educated guess as to the file name and arguments given when the
357 process was created by examining memory or the swap area.
358 The method is inherently somewhat unreliable and in any event a process
359 is entitled to destroy this information, so the names cannot be depended
360 on too much.
361 The
362 .Cm ucomm
363 (accounting) keyword can, however, be depended on.
364 .Sh KEYWORDS
365 The following is a complete list of the available keywords and their
366 meanings.
367 Several of them have aliases (keywords which are synonyms).
368 .Pp
369 .Bl -tag -width ".Cm sigignore" -compact
370 .It Cm %cpu
371 percentage CPU usage (alias
372 .Cm pcpu )
373 .It Cm %mem
374 percentage memory usage (alias
375 .Cm pmem )
376 .It Cm acflag
377 accounting flag (alias
378 .Cm acflg )
379 .It Cm batch
380 batchness of the process (higher numbers mean less interactivity)
381 .It Cm command
382 command and arguments
383 .It Cm cpu
384 short-term CPU usage factor (for scheduling)
385 .It Cm f
386 the process flags, in hexadecimal (alias
387 .Cm flags )
388 .It Cm inblk
389 total blocks read (alias
390 .Cm inblock )
391 .It Cm jail
392 jail ID
393 .It Cm jobc
394 job control count
395 .It Cm ktrace
396 tracing flags
397 .It Cm ktracep
398 tracing vnode
399 .It Cm lastcpu
400 CPU ID the process was last scheduled on
401 .It Cm lim
402 memoryuse limit
403 .It Cm login
404 login name of user who started the process (alias
405 .Cm logname )
406 .It Cm lstart
407 time started
408 .It Cm majflt
409 total page faults
410 .It Cm minflt
411 total page reclaims
412 .It Cm msgrcv
413 total messages received (reads from pipes/sockets)
414 .It Cm msgsnd
415 total messages sent (writes on pipes/sockets)
416 .It Cm nice
417 nice value (alias
418 .Cm ni )
419 .It Cm nivcsw
420 total involuntary context switches
421 .It Cm nsigs
422 total signals taken (alias
423 .Cm nsignals )
424 .It Cm nswap
425 total swaps in/out
426 .It Cm nvcsw
427 total voluntary context switches
428 .It Cm nwchan
429 wait channel (as an address)
430 .It Cm oublk
431 total blocks written (alias
432 .Cm oublock )
433 .It Cm p_ru
434 resource usage (valid only for zombie)
435 .It Cm paddr
436 swap address
437 .It Cm pagein
438 pageins (same as
439 .Cm majflt )
440 .It Cm pgid
441 process group number
442 .It Cm pid
443 process ID
444 .It Cm ppid
445 parent process ID
446 .It Cm pri
447 scheduling priority (lower == better)
448 .It Cm re
449 core residency time (in seconds; 127 = infinity)
450 .It Cm rgid
451 real group ID
452 .It Cm rlink
453 reverse link on run queue, or 0
454 .It Cm rss
455 resident set size
456 .It Cm rsz
457 resident set size + (text size / text use count) (alias
458 .Cm rssize )
459 .It Cm rtprio
460 realtime priority (101 = not a realtime process)
461 .It Cm ruid
462 real user ID
463 .It Cm ruser
464 user name (from ruid)
465 .It Cm sess
466 session pointer
467 .It Cm sig
468 pending signals (alias
469 .Cm pending )
470 .It Cm sigcatch
471 caught signals (alias
472 .Cm caught )
473 .It Cm sigignore
474 ignored signals (alias
475 .Cm ignored )
476 .It Cm sigmask
477 blocked signals (alias
478 .Cm blocked )
479 .It Cm sl
480 sleep time (in seconds; 127 = infinity)
481 .It Cm start
482 time started
483 .It Cm state
484 symbolic process state (alias
485 .Cm stat )
486 .It Cm svgid
487 saved gid from a setgid executable
488 .It Cm svuid
489 saved uid from a setuid executable
490 .It Cm tdev
491 control terminal device number
492 .It Cm tdpri
493 LWKT thread priority (0-31, 31 highest), and critical section count
494 .It Cm time
495 accumulated CPU time, user + system (alias
496 .Cm cputime )
497 .It Cm tpgid
498 control terminal process group ID
499 .\".It Cm trss
500 .\"text resident set size (in Kbytes)
501 .It Cm tsess
502 control terminal session pointer
503 .It Cm tsiz
504 text size (in Kbytes)
505 .It Cm tt
506 control terminal name (two letter abbreviation)
507 .It Cm tty
508 full name of control terminal
509 .It Cm ucomm
510 name to be used for accounting
511 .It Cm uid
512 effective user ID
513 .It Cm user
514 user name (from uid)
515 .It Cm vsz
516 virtual size in Kbytes (alias
517 .Cm vsize )
518 .It Cm wchan
519 wait channel (as a symbolic name)
520 .It Cm xstat
521 exit or stop status (valid only for stopped or zombie process)
522 .El
523 .Sh FILES
524 .Bl -tag -width /var/db/kvm_kernel.db -compact
525 .It Pa /dev/kmem
526 default kernel memory
527 .It Pa /var/run/dev.db
528 /dev name database
529 .It Pa /var/db/kvm_kernel.db
530 system namelist database
531 .It Pa /kernel
532 default system namelist
533 .It Pa /proc
534 the mount point of
535 .Xr procfs 5
536 .El
537 .Sh SEE ALSO
538 .Xr kill 1 ,
539 .Xr w 1 ,
540 .Xr kvm 3 ,
541 .Xr strftime 3 ,
542 .Xr procfs 5 ,
543 .Xr pstat 8 ,
544 .Xr sysctl 8
545 .Sh HISTORY
546 The
547 .Nm
548 command appeared in
549 .At v4 .
550 .Sh BUGS
551 Since
552 .Nm
553 cannot run faster than the system and is run as any other scheduled
554 process, the information it displays can never be exact.