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$ 34.\" 35.Dd April 18, 1994 36.Dt PS 1 37.Os 38.Sh NAME 39.Nm ps 40.Nd process status 41.Sh SYNOPSIS 42.Nm 43.Op Fl aCcefhjlmrSTuvwxZ 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.Oo Fl U Ar username Ns Xo 51.Op , Ns Ar username Ns No ... 52.Xc 53.Oc 54.Nm 55.Op Fl L 56.Sh DESCRIPTION 57The 58.Nm 59utility 60displays a header line followed by lines containing information about your 61processes that have controlling terminals. 62This information is sorted by controlling terminal, then by process 63.Tn ID . 64.Pp 65The information displayed is selected based on a set of keywords (see the 66.Fl L 67.Fl O 68and 69.Fl o 70options). 71The default output format includes, for each process, the process' 72.Tn ID , 73controlling terminal, cpu time (including both user and system time), 74state, and associated command. 75.Pp 76The process file system (see 77.Xr procfs 5 ) 78should be mounted when 79.Nm 80is executed, otherwise not all information will be available. 81.Pp 82The options are as follows: 83.Bl -tag -width indent 84.It Fl a 85Display information about other users' processes as well as your own. 86This can be disabled by setting the 87.Va security.bsd.see_other_uids 88sysctl to zero. 89.It Fl c 90Change the ``command'' column output to just contain the executable name, 91rather than the full command line. 92.It Fl C 93Change the way the cpu percentage is calculated by using a ``raw'' 94cpu calculation that ignores ``resident'' time (this normally has 95no effect). 96.It Fl e 97Display the environment as well. 98.It Fl f 99Show commandline and environment information about swapped out processes. 100This option is honored only if the uid of the user is 0. 101.It Fl h 102Repeat the information header as often as necessary to guarantee one 103header per page of information. 104.It Fl j 105Print information associated with the following keywords: 106user, pid, ppid, pgid, jobc, state, tt, time and command. 107.It Fl L 108List the set of available keywords. 109.It Fl l 110Display information associated with the following keywords: 111uid, pid, ppid, cpu, pri, nice, vsz, rss, mwchan, state, tt, time 112and 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 119.Tn ID . 120.It Fl N 121Extract the name list from the specified system instead of the default 122.Pa /boot/kernel/kernel . 123.It Fl O 124Add the information associated with the space or comma separated list 125of keywords specified, after the process 126.Tn ID , 127in the default information 128display. 129Keywords may be appended with an equals (``='') sign and a string. 130This causes the printed header to use the specified string instead of 131the standard header. 132.It Fl o 133Display information associated with the space or comma separated 134list of keywords specified. 135Multiple keywords may also be given in the form of more than one 136.Fl o 137option. 138Keywords may be appended with an equals (``='') sign and a string. 139This causes the printed header to use the specified string instead of 140the standard header. 141.It Fl p 142Display information associated with the specified process 143.Tn ID . 144.It Fl r 145Sort by current cpu usage, instead of by process 146.Tn ID . 147.It Fl S 148Change the way the process time is calculated by summing all exited 149children to their parent process. 150.It Fl T 151Display information about processes attached to the device associated 152with the standard input. 153.It Fl t 154Display information about processes attached to the specified terminal 155device. 156.It Fl U 157Display the processes belonging to the specified 158.Ar username Ns (s) . 159.It Fl u 160Display information associated with the following keywords: 161user, pid, %cpu, %mem, vsz, rss, tt, state, start, time and command. 162The 163.Fl u 164option implies the 165.Fl r 166option. 167.It Fl v 168Display information associated with the following keywords: 169pid, state, time, sl, re, pagein, vsz, rss, lim, tsiz, 170%cpu, %mem and command. 171The 172.Fl v 173option implies the 174.Fl m 175option. 176.It Fl w 177Use 132 columns to display information, instead of the default which 178is your window size. 179If the 180.Fl w 181option is specified more than once, 182.Nm 183will use as many columns as necessary without regard for your window size. 184.It Fl x 185Display information about processes without controlling terminals. 186.It Fl Z 187Add label to the list of keywords for which 188.Nm 189will display information. 190.El 191.Pp 192A complete list of the available keywords are listed below. 193Some of these keywords are further specified as follows: 194.Bl -tag -width lockname 195.It %cpu 196The cpu utilization of the process; this is a decaying average over up to 197a minute of previous (real) time. 198Since the time base over which this is computed varies (since processes may 199be very young) it is possible for the sum of all 200.Tn \&%CPU 201fields to exceed 100%. 202.It %mem 203The percentage of real memory used by this process. 204.It flags 205The flags associated with the process as in 206the include file 207.Aq Pa sys/proc.h : 208.Bl -column P_NOCLDSTOP P_NOCLDSTOP 209.It Dv "P_ADVLOCK" Ta No "0x00001 Process may hold a POSIX advisory lock" 210.It Dv "P_CONTROLT" Ta No "0x00002 Has a controlling terminal" 211.It Dv "P_INMEM" Ta No "0x00004 Loaded into memory" 212.It Dv "P_NOCLDSTOP" Ta No "0x00008 No SIGCHLD when children stop" 213.It Dv "P_PPWAIT" Ta No "0x00010 Parent is waiting for child to exec/exit" 214.It Dv "P_PROFIL" Ta No "0x00020 Has started profiling" 215.It Dv "P_SELECT" Ta No "0x00040 Selecting; wakeup/waiting danger" 216.It Dv "P_SINTR" Ta No "0x00080 Sleep is interruptible" 217.It Dv "P_SUGID" Ta No "0x00100 Had set id privileges since last exec" 218.It Dv "P_SYSTEM" Ta No "0x00200 System proc: no sigs, stats or swapping" 219.It Dv "P_TIMEOUT" Ta No "0x00400 Timing out during sleep" 220.It Dv "P_TRACED" Ta No "0x00800 Debugged process being traced" 221.It Dv "P_WAITED" Ta No "0x01000 Debugging process has waited for child" 222.It Dv "P_WEXIT" Ta No "0x02000 Working on exiting" 223.It Dv "P_EXEC" Ta No "0x04000 Process called exec" 224.It Dv "P_OWEUPC" Ta No "0x20000 Owe process an addupc() call at next ast" 225.It Dv "P_SWAPPING" Ta No "0x40000 Process is being swapped" 226.El 227.It label 228The MAC label of the process. 229.It lim 230The soft limit on memory used, specified via a call to 231.Xr setrlimit 2 . 232.It lstart 233The exact time the command started, using the ``%c'' format described in 234.Xr strftime 3 . 235.It lockname 236The name of the lock that the process is currently blocked on. 237If the name is invalid or unknown, then 238.Dq ???\& 239is displayed. 240.It mwchan 241The event name if the process is blocked normally, or the lock name if 242the process is blocked on a lock. 243See the wchan and lockname keywords 244for details. 245.It nice 246The process scheduling increment (see 247.Xr setpriority 2 ) . 248.It rss 249the real memory (resident set) size of the process (in 1024 byte units). 250.It start 251The time the command started. 252If the command started less than 24 hours ago, the start time is 253displayed using the ``%l:ps.1p'' format described in 254.Xr strftime 3 . 255If the command started less than 7 days ago, the start time is 256displayed using the ``%a6.15p'' format. 257Otherwise, the start time is displayed using the ``%e%b%y'' format. 258.It state 259The state is given by a sequence of letters, for example, 260.Dq Tn RWNA . 261The first letter indicates the run state of the process: 262.Pp 263.Bl -tag -width indent -compact 264.It D 265Marks a process in disk (or other short term, uninterruptible) wait. 266.It I 267Marks a process that is idle (sleeping for longer than about 20 seconds). 268.It J 269Marks a process which is in 270.Xr jail 2 . 271The hostname of the prison can be found in 272.Ql /proc/<pid>/status . 273.It L 274Marks a process that is waiting to acquire a lock. 275.It R 276Marks a runnable process. 277.It S 278Marks a process that is sleeping for less than about 20 seconds. 279.It T 280Marks a stopped process. 281.It Z 282Marks a dead process (a ``zombie''). 283.El 284.Pp 285Additional characters after these, if any, indicate additional state 286information: 287.Pp 288.Bl -tag -width indent -compact 289.It + 290The process is in the foreground process group of its control terminal. 291.It < 292The process has raised 293.Tn CPU 294scheduling priority. 295.It > 296The process has specified a soft limit on memory requirements and is 297currently exceeding that limit; such a process is (necessarily) not 298swapped. 299.It A 300the process has asked for random page replacement 301.Pf ( Dv MADV_RANDOM , 302from 303.Xr madvise 2 , 304for example, 305.Xr lisp 1 306in a garbage collect). 307.It E 308The process is trying to exit. 309.It L 310The process has pages locked in core (for example, for raw 311.Tn I/O ) . 312.It N 313The process has reduced 314.Tn CPU 315scheduling priority (see 316.Xr setpriority 2 ) . 317.It S 318The process has asked for 319.Tn FIFO 320page replacement 321.Pf ( Dv MADV_SEQUENTIAL , 322from 323.Xr madvise 2 , 324for example, a large image processing program using virtual memory to 325sequentially address voluminous data). 326.It s 327The process is a session leader. 328.It V 329The process is suspended during a 330.Xr vfork . 331.It W 332The process is swapped out. 333.It X 334The process is being traced or debugged. 335.El 336.It tt 337An abbreviation for the pathname of the controlling terminal, if any. 338The abbreviation consists of the three letters following 339.Pa /dev/tty , 340or, for the console, ``con''. 341This is followed by a ``-'' if the process can no longer reach that 342controlling terminal (i.e., it has been revoked). 343.It wchan 344The event (an address in the system) on which a process waits. 345When printed numerically, the initial part of the address is 346trimmed off and the result is printed in hex, for example, 0x80324000 prints 347as 324000. 348.El 349.Pp 350When printing using the command keyword, a process that has exited and 351has a parent that has not yet waited for the process (in other words, a zombie) 352is listed as ``<defunct>'', and a process which is blocked while trying 353to exit is listed as ``<exiting>''. 354The 355.Nm 356utility 357makes an educated guess as to the file name and arguments given when the 358process was created by examining memory or the swap area. 359The method is inherently somewhat unreliable and in any event a process 360is entitled to destroy this information, so the names cannot be depended 361on too much. 362The ucomm (accounting) keyword can, however, be depended on. 363.Sh KEYWORDS 364The following is a complete list of the available keywords and their 365meanings. 366Several of them have aliases (keywords which are synonyms). 367.Pp 368.Bl -tag -width sigignore -compact 369.It %cpu 370percentage cpu usage (alias pcpu) 371.It %mem 372percentage memory usage (alias pmem) 373.It acflag 374accounting flag (alias acflg) 375.It args 376command and arguments 377.It comm 378command 379.It command 380command and arguments 381.It cpu 382short-term cpu usage factor (for scheduling) 383.It etime 384elapsed running time 385.It flags 386the process flags, in hexadecimal (alias f) 387.It inblk 388total blocks read (alias inblock) 389.It jobc 390job control count 391.It ktrace 392tracing flags 393.It label 394MAC label 395.It lim 396memoryuse limit 397.It logname 398login name of user who started the process 399.It lstart 400time started 401.It majflt 402total page faults 403.It minflt 404total page reclaims 405.It msgrcv 406total messages received (reads from pipes/sockets) 407.It msgsnd 408total messages sent (writes on pipes/sockets) 409.It lockname 410lock currently blocked on (as a symbolic name) 411.It mwchan 412wait channel or lock currently blocked on 413.It nice 414nice value (alias ni) 415.It nivcsw 416total involuntary context switches 417.It nsigs 418total signals taken (alias nsignals) 419.It nswap 420total swaps in/out 421.It nvcsw 422total voluntary context switches 423.It nwchan 424wait channel (as an address) 425.It oublk 426total blocks written (alias oublock) 427.It paddr 428swap address 429.It pagein 430pageins (same as majflt) 431.It pgid 432process group number 433.It pid 434process 435.Tn ID 436.It poip 437pageouts in progress 438.It ppid 439parent process 440.Tn ID 441.It pri 442scheduling priority 443.It re 444core residency time (in seconds; 127 = infinity) 445.It rgid 446real group 447.Tn ID 448.It rgroup 449group name (from rgid) 450.It rlink 451reverse link on run queue, or 0 452.It rss 453resident set size 454.It rtprio 455realtime priority (101 = not a realtime process) 456.It ruid 457real user 458.Tn ID 459.It ruser 460user name (from ruid) 461.It sid 462session 463.Tn ID 464.It sig 465pending signals (alias pending) 466.It sigcatch 467caught signals (alias caught) 468.It sigignore 469ignored signals (alias ignored) 470.It sigmask 471blocked signals (alias blocked) 472.It sl 473sleep time (in seconds; 127 = infinity) 474.It start 475time started 476.It state 477symbolic process state (alias stat) 478.It svgid 479saved gid from a setgid executable 480.It svuid 481saved uid from a setuid executable 482.It tdev 483control terminal device number 484.It time 485accumulated cpu time, user + system (alias cputime) 486.It tpgid 487control terminal process group 488.Tn ID 489.\".It trss 490.\"text resident set size (in Kbytes) 491.It tsid 492control terminal session 493.Tn ID 494.It tsiz 495text size (in Kbytes) 496.It tt 497control terminal name (two letter abbreviation) 498.It tty 499full name of control terminal 500.It uprocp 501process pointer 502.It ucomm 503name to be used for accounting 504.It uid 505effective user 506.Tn ID 507.It upr 508scheduling priority on return from system call (alias usrpri) 509.It user 510user name (from uid) 511.It vsz 512virtual size in Kbytes (alias vsize) 513.It wchan 514wait channel (as a symbolic name) 515.It xstat 516exit or stop status (valid only for stopped or zombie process) 517.El 518.Sh ENVIRONMENT 519The following environment variables affect the execution of 520.Nm : 521.Bl -tag -width ".Ev COLUMNS" 522.It Ev COLUMNS 523If set, specifies the user's preferred output width in column positions. 524By default, 525.Nm 526attempts to automatically determine the terminal width. 527.El 528.Sh FILES 529.Bl -tag -width /var/db/kvm_kernel.db -compact 530.It Pa /dev/kmem 531default kernel memory 532.It Pa /dev/lomac 533interface used to query the 534.Xr lomac 4 535KLD 536.It Pa /var/run/dev.db 537/dev name database 538.It Pa /var/db/kvm_kernel.db 539system namelist database 540.It Pa /boot/kernel/kernel 541default system namelist 542.It Pa /proc 543the mount point of 544.Xr procfs 5 545.El 546.Sh SEE ALSO 547.Xr kill 1 , 548.Xr w 1 , 549.Xr kvm 3 , 550.Xr strftime 3 , 551.Xr lomac 4 , 552.Xr procfs 5 , 553.Xr pstat 8 , 554.Xr sysctl 8 , 555.Xr mutex 9 556.Sh HISTORY 557The 558.Nm 559command appeared in 560.At v4 . 561.Sh BUGS 562Since 563.Nm 564cannot run faster than the system and is run as any other scheduled 565process, the information it displays can never be exact. 566