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