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