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