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> . 417If the command vector cannot be located (usually because it has not 418been set, as is the case of system processes and/or kernel threads) 419the command name is printed within square brackets. 420The 421.Nm 422utility 423makes an educated guess as to the file name and arguments given when the 424process was created by examining memory or the swap area. 425The method is inherently somewhat unreliable and in any event a process 426is entitled to destroy this information, so the names cannot be depended 427on too much. 428The ucomm (accounting) keyword can, however, be depended on. 429.Sh KEYWORDS 430The following is a complete list of the available keywords and their 431meanings. 432Several of them have aliases (keywords which are synonyms). 433.Pp 434.Bl -tag -width ".Cm sigignore" -compact 435.It Cm %cpu 436percentage CPU usage (alias 437.Cm pcpu ) 438.It Cm %mem 439percentage memory usage (alias 440.Cm pmem ) 441.It Cm acflag 442accounting flag (alias 443.Cm acflg ) 444.It Cm args 445command and arguments 446.It Cm comm 447command 448.It Cm command 449command and arguments 450.It Cm cpu 451short-term CPU usage factor (for scheduling) 452.It Cm etime 453elapsed running time 454.It Cm flags 455the process flags, in hexadecimal (alias 456.Cm f ) 457.It Cm inblk 458total blocks read (alias 459.Cm inblock ) 460.It Cm jobc 461job control count 462.It Cm ktrace 463tracing flags 464.It Cm label 465MAC label 466.It Cm lim 467memoryuse limit 468.It Cm logname 469login name of user who started the process 470.It Cm lstart 471time started 472.It Cm majflt 473total page faults 474.It Cm minflt 475total page reclaims 476.It Cm msgrcv 477total messages received (reads from pipes/sockets) 478.It Cm msgsnd 479total messages sent (writes on pipes/sockets) 480.It Cm lockname 481lock currently blocked on (as a symbolic name) 482.It Cm mwchan 483wait channel or lock currently blocked on 484.It Cm nice 485nice value (alias 486.Cm ni ) 487.It Cm nivcsw 488total involuntary context switches 489.It Cm nsigs 490total signals taken (alias 491.Cm nsignals ) 492.It Cm nswap 493total swaps in/out 494.It Cm nvcsw 495total voluntary context switches 496.It Cm nwchan 497wait channel (as an address) 498.It Cm oublk 499total blocks written (alias 500.Cm oublock ) 501.It Cm paddr 502swap address 503.It Cm pagein 504pageins (same as majflt) 505.It Cm pgid 506process group number 507.It Cm pid 508process ID 509.It Cm poip 510pageouts in progress 511.It Cm ppid 512parent process ID 513.It Cm pri 514scheduling priority 515.It Cm re 516core residency time (in seconds; 127 = infinity) 517.It Cm rgid 518real group ID 519.It Cm rgroup 520group name (from rgid) 521.It Cm rlink 522reverse link on run queue, or 0 523.It Cm rss 524resident set size 525.It Cm rtprio 526realtime priority (101 = not a realtime process) 527.It Cm ruid 528real user ID 529.It Cm ruser 530user name (from ruid) 531.It Cm sid 532session ID 533.It Cm sig 534pending signals (alias 535.Cm pending ) 536.It Cm sigcatch 537caught signals (alias 538.Cm caught ) 539.It Cm sigignore 540ignored signals (alias 541.Cm ignored ) 542.It Cm sigmask 543blocked signals (alias 544.Cm blocked ) 545.It Cm sl 546sleep time (in seconds; 127 = infinity) 547.It Cm start 548time started 549.It Cm state 550symbolic process state (alias 551.Cm stat ) 552.It Cm svgid 553saved gid from a setgid executable 554.It Cm svuid 555saved UID from a setuid executable 556.It Cm tdev 557control terminal device number 558.It Cm time 559accumulated CPU time, user + system (alias 560.Cm cputime ) 561.It Cm tpgid 562control terminal process group ID 563.\".It Cm trss 564.\"text resident set size (in Kbytes) 565.It Cm tsid 566control terminal session ID 567.It Cm tsiz 568text size (in Kbytes) 569.It Cm tt 570control terminal name (two letter abbreviation) 571.It Cm tty 572full name of control terminal 573.It Cm uprocp 574process pointer 575.It Cm ucomm 576name to be used for accounting 577.It Cm uid 578effective user ID 579.It Cm upr 580scheduling priority on return from system call (alias 581.Cm usrpri ) 582.It Cm user 583user name (from UID) 584.It Cm vsz 585virtual size in Kbytes (alias 586.Cm vsize ) 587.It Cm wchan 588wait channel (as a symbolic name) 589.It Cm xstat 590exit or stop status (valid only for stopped or zombie process) 591.El 592.Sh ENVIRONMENT 593The following environment variables affect the execution of 594.Nm : 595.Bl -tag -width ".Ev COLUMNS" 596.It Ev COLUMNS 597If set, specifies the user's preferred output width in column positions. 598By default, 599.Nm 600attempts to automatically determine the terminal width. 601.El 602.Sh FILES 603.Bl -tag -width ".Pa /boot/kernel/kernel" -compact 604.It Pa /dev/lomac 605interface used to query the 606.Xr lomac 4 607KLD 608.It Pa /boot/kernel/kernel 609default system namelist 610.It Pa /proc 611the mount point of 612.Xr procfs 5 613.El 614.Sh SEE ALSO 615.Xr kill 1 , 616.Xr pgrep 1 , 617.Xr pkill 1 , 618.Xr w 1 , 619.Xr kvm 3 , 620.Xr strftime 3 , 621.Xr lomac 4 , 622.Xr procfs 5 , 623.Xr pstat 8 , 624.Xr sysctl 8 , 625.Xr mutex 9 626.Sh STANDARDS 627For historical reasons, 628.Nm 629utility under 630.Fx 631supports a different set of options from what is described by 632.St -p1003.2 , 633and what is supported on 634.No non- Ns Bx 635operating systems. 636.Sh HISTORY 637The 638.Nm 639command appeared in 640.At v4 . 641.Sh BUGS 642Since 643.Nm 644cannot run faster than the system and is run as any other scheduled 645process, the information it displays can never be exact. 646.Pp 647The 648.Nm 649utility does not correctly display argument lists containing multibyte 650characters. 651