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