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