1.\"- 2.\" Copyright (c) 1980, 1990, 1991, 1993, 1994 3.\" The Regents of the University of California. All rights reserved. 4.\" 5.\" Redistribution and use in source and binary forms, with or without 6.\" modification, are permitted provided that the following conditions 7.\" are met: 8.\" 1. Redistributions of source code must retain the above copyright 9.\" notice, this list of conditions and the following disclaimer. 10.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" notice, this list of conditions and the following disclaimer in the 12.\" documentation and/or other materials provided with the distribution. 13.\" 4. Neither the name of the University nor the names of its contributors 14.\" may be used to endorse or promote products derived from this software 15.\" without specific prior written permission. 16.\" 17.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27.\" SUCH DAMAGE. 28.\" 29.\" @(#)ps.1 8.3 (Berkeley) 4/18/94 30.\" $FreeBSD$ 31.\" 32.Dd March 27, 2004 33.Dt PS 1 34.Os 35.Sh NAME 36.Nm ps 37.Nd process status 38.Sh SYNOPSIS 39.Nm 40.Op Fl aCcefHhjlmrSTuvwXxZ 41.Op Fl G Ar gid Ns Op , Ns Ar gid Ns Ar ... 42.Op Fl M Ar core 43.Op Fl N Ar system 44.Op Fl O Ar fmt 45.Op Fl o Ar fmt 46.Op Fl p Ar pid Ns Op , Ns Ar pid Ns Ar ... 47.Op Fl t Ar tty Ns Op , Ns Ar tty Ns Ar ... 48.Op Fl U Ar username Ns Op , Ns Ar username Ns Ar ... 49.Nm 50.Op Fl L 51.Sh DESCRIPTION 52The 53.Nm 54utility 55displays a header line, followed by lines containing information about 56all of your 57processes that have controlling terminals. 58.Pp 59A different set of processes can be selected for display by using any 60combination of the 61.Fl a , G , p , T , t , 62and 63.Fl U 64options. 65If more than one of these options are given, then 66.Nm 67will select all processes which are matched by at least one of the 68given options. 69.Pp 70For the processes which have been selected for display, 71.Nm 72will usually display one line per process. 73The 74.Fl H 75option may result in multiple output lines (one line per thread) for 76some processes. 77By default all of these output lines are sorted first by controlling 78terminal, then by process ID. 79The 80.Fl m , r , u , 81and 82.Fl v 83options will change the sort order. 84If more than one sorting option was given, then the selected processes 85will be sorted by the last sorting option which was specified. 86.Pp 87For the processes which have been selected for display, the information 88to display is selected based on a set of keywords (see the 89.Fl L , O , 90and 91.Fl o 92options). 93The default output format includes, for each process, the process' ID, 94controlling terminal, CPU time (including both user and system time), 95state, and associated command. 96.Pp 97The process file system (see 98.Xr procfs 5 ) 99should be mounted when 100.Nm 101is executed, otherwise not all information will be available. 102.Pp 103The options are as follows: 104.Bl -tag -width indent 105.It Fl a 106Display information about other users' processes as well as your own. 107This will skip any processes which do not have a controlling teminal, 108unless the 109.Fl x 110option is also specified. 111This can be disabled by setting the 112.Va security.bsd.see_other_uids 113sysctl to zero. 114.It Fl c 115Change the 116.Dq command 117column output to just contain the executable name, 118rather than the full command line. 119.It Fl C 120Change the way the CPU percentage is calculated by using a 121.Dq raw 122CPU calculation that ignores 123.Dq resident 124time (this normally has 125no effect). 126.It Fl e 127Display the environment as well. 128.It Fl f 129Show commandline and environment information about swapped out processes. 130This option is honored only if the UID of the user is 0. 131.It Fl G 132Display information about processes which are running with the specified 133real group IDs. 134.It Fl H 135Show all of the 136.Em kernel visible 137threads associated with each process. 138Depending on the threading package that 139is in use, this may show only the process, only the kernel scheduled entities, 140or all of the process threads. 141.It Fl h 142Repeat the information header as often as necessary to guarantee one 143header per page of information. 144.It Fl j 145Print information associated with the following keywords: 146.Cm user , pid , ppid , pgid , sid , jobc , state , tt , time , 147and 148.Cm command . 149.It Fl L 150List the set of keywords available for the 151.Fl O 152and 153.Fl o 154options. 155.It Fl l 156Display information associated with the following keywords: 157.Cm uid , pid , ppid , cpu , pri , nice , vsz , rss , mwchan , state , 158.Cm tt , time , 159and 160.Cm command . 161.It Fl M 162Extract values associated with the name list from the specified core 163instead of the currently running system. 164.It Fl m 165Sort by memory usage, instead of the combination of controlling 166terminal and process ID. 167.It Fl N 168Extract the name list from the specified system instead of the default, 169which is the kernel image the system has booted from. 170.It Fl O 171Add the information associated with the space or comma separated list 172of keywords specified, after the process ID, 173in the default information 174display. 175Keywords may be appended with an equals 176.Pq Ql = 177sign and a string. 178This causes the printed header to use the specified string instead of 179the standard header. 180.It Fl o 181Display information associated with the space or comma separated 182list of keywords specified. 183Multiple keywords may also be given in the form of more than one 184.Fl o 185option. 186Keywords may be appended with an equals 187.Pq Ql = 188sign and a string. 189This causes the printed header to use the specified string instead of 190the standard header. 191.It Fl p 192Display information about processes which match the specified process IDs. 193.It Fl r 194Sort by current CPU usage, instead of the combination of controlling 195terminal and process ID. 196.It Fl S 197Change the way the process time is calculated by summing all exited 198children to their parent process. 199.It Fl T 200Display information about processes attached to the device associated 201with the standard input. 202.It Fl t 203Display information about processes attached to the specified terminal 204devices. 205.It Fl U 206Display the processes belonging to the specified usernames. 207.It Fl u 208Display information associated with the following keywords: 209.Cm user , pid , %cpu , %mem , vsz , rss , tt , state , start , time , 210and 211.Cm command . 212The 213.Fl u 214option implies the 215.Fl r 216option. 217.It Fl v 218Display information associated with the following keywords: 219.Cm pid , state , time , sl , re , pagein , vsz , rss , lim , tsiz , 220.Cm %cpu , %mem , 221and 222.Cm command . 223The 224.Fl v 225option implies the 226.Fl m 227option. 228.It Fl w 229Use 132 columns to display information, instead of the default which 230is your window size. 231If the 232.Fl w 233option is specified more than once, 234.Nm 235will use as many columns as necessary without regard for your window size. 236.It Fl X 237When displaying processes matched by other options, skip any processes 238which do not have a controlling terminal. 239.It Fl x 240When displaying processes matched by other options, include processes 241which do not have a controlling terminal. 242This is the opposite of the 243.Fl X 244option. 245If both 246.Fl X 247and 248.Fl x 249are specified in the same command, then 250.Nm 251will use the one which was specified last. 252.It Fl Z 253Add 254.Xr mac 4 255label to the list of keywords for which 256.Nm 257will display information. 258.El 259.Pp 260A complete list of the available keywords are listed below. 261Some of these keywords are further specified as follows: 262.Bl -tag -width lockname 263.It Cm %cpu 264The CPU utilization of the process; this is a decaying average over up to 265a minute of previous (real) time. 266Since the time base over which this is computed varies (since processes may 267be very young) it is possible for the sum of all 268.Cm %cpu 269fields to exceed 100%. 270.It Cm %mem 271The percentage of real memory used by this process. 272.It Cm flags 273The flags associated with the process as in 274the include file 275.In sys/proc.h : 276.Bl -column P_STOPPED_SINGLE 0x4000000 277.It Dv "P_ADVLOCK" Ta No "0x00001 Process may hold a POSIX advisory lock" 278.It Dv "P_CONTROLT" Ta No "0x00002 Has a controlling terminal" 279.It Dv "P_KTHREAD" Ta No "0x00004 Kernel thread" 280.It Dv "P_NOLOAD" Ta No "0x00008 Ignore during load avg calculations" 281.It Dv "P_PPWAIT" Ta No "0x00010 Parent is waiting for child to exec/exit" 282.It Dv "P_PROFIL" Ta No "0x00020 Has started profiling" 283.It Dv "P_STOPPROF" Ta No "0x00040 Has thread in requesting to stop prof" 284.It Dv "P_SUGID" Ta No "0x00100 Had set id privileges since last exec" 285.It Dv "P_SYSTEM" Ta No "0x00200 System proc: no sigs, stats or swapping" 286.It Dv "P_SINGLE_EXIT" Ta No "0x00400 Threads suspending should exit, not wait" 287.It Dv "P_TRACED" Ta No "0x00800 Debugged process being traced" 288.It Dv "P_WAITED" Ta No "0x01000 Someone is waiting for us" 289.It Dv "P_WEXIT" Ta No "0x02000 Working on exiting" 290.It Dv "P_EXEC" Ta No "0x04000 Process called exec" 291.It Dv "P_SA" Ta No "0x08000 Using scheduler activations" 292.It Dv "P_CONTINUED" Ta No "0x10000 Proc has continued from a stopped state" 293.It Dv "P_STOPPED_SIG" Ta No "0x20000 Stopped due to SIGSTOP/SIGTSTP" 294.It Dv "P_STOPPED_TRACE" Ta No "0x40000 Stopped because of tracing" 295.It Dv "P_STOPPED_SINGLE" Ta No "0x80000 Only one thread can continue" 296.It Dv "P_PROTECTED" Ta No "0x100000 Do not kill on memory overcommit" 297.It Dv "P_SIGEVENT" Ta No "0x200000 Process pending signals changed" 298.It Dv "P_JAILED" Ta No "0x1000000 Process is in jail" 299.It Dv "P_INEXEC" Ta No "0x4000000 Process is in execve()" 300.El 301.It Cm label 302The MAC label of the process. 303.It Cm lim 304The soft limit on memory used, specified via a call to 305.Xr setrlimit 2 . 306.It Cm lstart 307The exact time the command started, using the 308.Ql %c 309format described in 310.Xr strftime 3 . 311.It Cm lockname 312The name of the lock that the process is currently blocked on. 313If the name is invalid or unknown, then 314.Dq ???\& 315is displayed. 316.It Cm mwchan 317The event name if the process is blocked normally, or the lock name if 318the process is blocked on a lock. 319See the wchan and lockname keywords 320for details. 321.It Cm nice 322The process scheduling increment (see 323.Xr setpriority 2 ) . 324.It Cm rss 325the real memory (resident set) size of the process (in 1024 byte units). 326.It Cm start 327The time the command started. 328If the command started less than 24 hours ago, the start time is 329displayed using the 330.Dq Li %l:ps.1p 331format described in 332.Xr strftime 3 . 333If the command started less than 7 days ago, the start time is 334displayed using the 335.Dq Li %a6.15p 336format. 337Otherwise, the start time is displayed using the 338.Dq Li %e%b%y 339format. 340.It Cm state 341The state is given by a sequence of characters, for example, 342.Dq Li RWNA . 343The first character indicates the run state of the process: 344.Pp 345.Bl -tag -width indent -compact 346.It Li D 347Marks a process in disk (or other short term, uninterruptible) wait. 348.It Li I 349Marks a process that is idle (sleeping for longer than about 20 seconds). 350.It Li L 351Marks a process that is waiting to acquire a lock. 352.It Li R 353Marks a runnable process. 354.It Li S 355Marks a process that is sleeping for less than about 20 seconds. 356.It Li T 357Marks a stopped process. 358.It Li W 359Marks an idle interrupt thread. 360.It Li Z 361Marks a dead process (a 362.Dq zombie ) . 363.El 364.Pp 365Additional characters after these, if any, indicate additional state 366information: 367.Pp 368.Bl -tag -width indent -compact 369.It Li + 370The process is in the foreground process group of its control terminal. 371.It Li < 372The process has raised CPU scheduling priority. 373.It Li E 374The process is trying to exit. 375.It Li J 376Marks a process which is in 377.Xr jail 2 . 378The hostname of the prison can be found in 379.Pa /proc/ Ns Ao Ar pid Ac Ns Pa /status . 380.It Li L 381The process has pages locked in core (for example, for raw 382.Tn I/O ) . 383.It Li N 384The process has reduced CPU scheduling priority (see 385.Xr setpriority 2 ) . 386.It Li s 387The process is a session leader. 388.It Li V 389The process is suspended during a 390.Xr vfork 2 . 391.It Li W 392The process is swapped out. 393.It Li X 394The process is being traced or debugged. 395.El 396.It Cm tt 397An abbreviation for the pathname of the controlling terminal, if any. 398The abbreviation consists of the three letters following 399.Pa /dev/tty , 400or, for the console, 401.Dq Li con . 402This is followed by a 403.Ql - 404if the process can no longer reach that 405controlling terminal (i.e., it has been revoked). 406.It Cm wchan 407The event (an address in the system) on which a process waits. 408When printed numerically, the initial part of the address is 409trimmed off and the result is printed in hex, for example, 0x80324000 prints 410as 324000. 411.El 412.Pp 413When printing using the command keyword, a process that has exited and 414has a parent that has not yet waited for the process (in other words, a zombie) 415is listed as 416.Dq Li <defunct> , 417and a process which is blocked while trying 418to exit is listed as 419.Dq Li <exiting> . 420If the command vector cannot be located (usually because it has not 421been set, as is the case of system processes and/or kernel threads) 422the command name is printed within square brackets. 423The 424.Nm 425utility 426makes an educated guess as to the file name and arguments given when the 427process was created by examining memory or the swap area. 428The method is inherently somewhat unreliable and in any event a process 429is entitled to destroy this information, so the names cannot be depended 430on too much. 431The ucomm (accounting) keyword can, however, be depended on. 432.Sh KEYWORDS 433The following is a complete list of the available keywords and their 434meanings. 435Several of them have aliases (keywords which are synonyms). 436.Pp 437.Bl -tag -width ".Cm sigignore" -compact 438.It Cm %cpu 439percentage CPU usage (alias 440.Cm pcpu ) 441.It Cm %mem 442percentage memory usage (alias 443.Cm pmem ) 444.It Cm acflag 445accounting flag (alias 446.Cm acflg ) 447.It Cm args 448command and arguments 449.It Cm comm 450command 451.It Cm command 452command and arguments 453.It Cm cpu 454short-term CPU usage factor (for scheduling) 455.It Cm etime 456elapsed running time 457.It Cm flags 458the process flags, in hexadecimal (alias 459.Cm f ) 460.It Cm inblk 461total blocks read (alias 462.Cm inblock ) 463.It Cm jobc 464job control count 465.It Cm ktrace 466tracing flags 467.It Cm label 468MAC label 469.It Cm lim 470memoryuse limit 471.It Cm logname 472login name of user who started the process 473.It Cm lstart 474time started 475.It Cm majflt 476total page faults 477.It Cm minflt 478total page reclaims 479.It Cm msgrcv 480total messages received (reads from pipes/sockets) 481.It Cm msgsnd 482total messages sent (writes on pipes/sockets) 483.It Cm lockname 484lock currently blocked on (as a symbolic name) 485.It Cm mwchan 486wait channel or lock currently blocked on 487.It Cm nice 488nice value (alias 489.Cm ni ) 490.It Cm nivcsw 491total involuntary context switches 492.It Cm nsigs 493total signals taken (alias 494.Cm nsignals ) 495.It Cm nswap 496total swaps in/out 497.It Cm nvcsw 498total voluntary context switches 499.It Cm nwchan 500wait channel (as an address) 501.It Cm oublk 502total blocks written (alias 503.Cm oublock ) 504.It Cm paddr 505swap address 506.It Cm pagein 507pageins (same as majflt) 508.It Cm pgid 509process group number 510.It Cm pid 511process ID 512.It Cm poip 513pageouts in progress 514.It Cm ppid 515parent process ID 516.It Cm pri 517scheduling priority 518.It Cm re 519core residency time (in seconds; 127 = infinity) 520.It Cm rgid 521real group ID 522.It Cm rgroup 523group name (from rgid) 524.It Cm rlink 525reverse link on run queue, or 0 526.It Cm rss 527resident set size 528.It Cm rtprio 529realtime priority (101 = not a realtime process) 530.It Cm ruid 531real user ID 532.It Cm ruser 533user name (from ruid) 534.It Cm sid 535session ID 536.It Cm sig 537pending signals (alias 538.Cm pending ) 539.It Cm sigcatch 540caught signals (alias 541.Cm caught ) 542.It Cm sigignore 543ignored signals (alias 544.Cm ignored ) 545.It Cm sigmask 546blocked signals (alias 547.Cm blocked ) 548.It Cm sl 549sleep time (in seconds; 127 = infinity) 550.It Cm start 551time started 552.It Cm state 553symbolic process state (alias 554.Cm stat ) 555.It Cm svgid 556saved gid from a setgid executable 557.It Cm svuid 558saved UID from a setuid executable 559.It Cm tdev 560control terminal device number 561.It Cm time 562accumulated CPU time, user + system (alias 563.Cm cputime ) 564.It Cm tpgid 565control terminal process group ID 566.\".It Cm trss 567.\"text resident set size (in Kbytes) 568.It Cm tsid 569control terminal session ID 570.It Cm tsiz 571text size (in Kbytes) 572.It Cm tt 573control terminal name (two letter abbreviation) 574.It Cm tty 575full name of control terminal 576.It Cm uprocp 577process pointer 578.It Cm ucomm 579name to be used for accounting 580.It Cm uid 581effective user ID 582.It Cm upr 583scheduling priority on return from system call (alias 584.Cm usrpri ) 585.It Cm user 586user name (from UID) 587.It Cm vsz 588virtual size in Kbytes (alias 589.Cm vsize ) 590.It Cm wchan 591wait channel (as a symbolic name) 592.It Cm xstat 593exit or stop status (valid only for stopped or zombie process) 594.El 595.Sh ENVIRONMENT 596The following environment variables affect the execution of 597.Nm : 598.Bl -tag -width ".Ev COLUMNS" 599.It Ev COLUMNS 600If set, specifies the user's preferred output width in column positions. 601By default, 602.Nm 603attempts to automatically determine the terminal width. 604.El 605.Sh FILES 606.Bl -tag -width ".Pa /boot/kernel/kernel" -compact 607.It Pa /boot/kernel/kernel 608default system namelist 609.It Pa /proc 610the mount point of 611.Xr procfs 5 612.El 613.Sh SEE ALSO 614.Xr kill 1 , 615.Xr pgrep 1 , 616.Xr pkill 1 , 617.Xr w 1 , 618.Xr kvm 3 , 619.Xr strftime 3 , 620.Xr mac 4 , 621.Xr procfs 5 , 622.Xr pstat 8 , 623.Xr sysctl 8 , 624.Xr mutex 9 625.Sh STANDARDS 626For historical reasons, 627.Nm 628utility under 629.Fx 630supports a different set of options from what is described by 631.St -p1003.2 , 632and what is supported on 633.No non- Ns Bx 634operating systems. 635.Sh HISTORY 636The 637.Nm 638command appeared in 639.At v4 . 640.Sh BUGS 641Since 642.Nm 643cannot run faster than the system and is run as any other scheduled 644process, the information it displays can never be exact. 645.Pp 646The 647.Nm 648utility does not correctly display argument lists containing multibyte 649characters. 650