1.\" $NetBSD: ps.1,v 1.70 2004/08/23 17:36:19 wiz Exp $ 2.\" 3.\" Copyright (c) 1980, 1990, 1991, 1993, 1994 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. Neither the name of the University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.\" @(#)ps.1 8.3 (Berkeley) 4/18/94 31.\" 32.Dd August 23, 2004 33.Dt PS 1 34.Os 35.Sh NAME 36.Nm ps 37.Nd process status 38.Sh SYNOPSIS 39.Nm 40.Op Fl acCehjlmrsSTuvwx 41.Bk -words 42.Op Fl k Ar key 43.Ek 44.Bk -words 45.Op Fl M Ar core 46.Ek 47.Bk -words 48.Op Fl N Ar system 49.Ek 50.Bk -words 51.Op Fl O Ar fmt 52.Ek 53.Bk -words 54.Op Fl o Ar fmt 55.Ek 56.Bk -words 57.Op Fl p Ar pid 58.Ek 59.Bk -words 60.Op Fl t Ar tty 61.Ek 62.Bk -words 63.Op Fl U Ar username 64.Ek 65.Bk -words 66.Op Fl W Ar swap 67.Ek 68.Nm 69.Op Fl L 70.Sh DESCRIPTION 71.Nm 72displays a header line followed by lines containing information about your 73processes that have controlling terminals. 74The default sort order of controlling terminal and 75(among processes with the same controlling terminal) process 76.Tn ID 77may be changed using the 78.Fl k 79option. 80.Pp 81The information displayed is selected based on a set of keywords (see the 82.Fl L 83.Fl O 84and 85.Fl o 86options). 87The default output format includes, for each process, the process' 88.Tn ID , 89controlling terminal, CPU time (including both user and system time), 90state, and associated command. 91.Pp 92The options are as follows: 93.Bl -tag -width indent 94.It Fl a 95Display information about other users' processes as well as your own. 96.It Fl c 97Do not display full command with arguments, but only the 98executable name. 99This may be somewhat confusing; for example, all 100.Xr sh 1 101scripts will show as 102.Dq sh . 103.It Fl C 104Change the way the CPU percentage is calculated by using a 105.Dq raw 106CPU calculation that ignores 107.Dq resident 108time (this normally has no effect). 109.It Fl e 110Display the environment as well. 111The environment for other 112users' processes can only be displayed by the super-user. 113.It Fl h 114Repeat the information header as often as necessary to guarantee one 115header per page of information. 116.It Fl j 117Print information associated with the following keywords: 118user, pid, ppid, pgid, sess, jobc, state, tt, time, and command. 119.It Fl k 120Sort the output using the space or comma separated list of keywords. 121.It Fl L 122List the set of available keywords. 123.It Fl l 124Display information associated with the following keywords: 125uid, pid, ppid, cpu, pri, nice, vsz, rss, wchan, state, tt, time, 126and command. 127.It Fl M 128Extract values from the specified core file instead of the running system. 129.It Fl m 130Sort by memory usage, instead of by process 131.Tn ID , 132equivalent to 133.Fl k 134.Ar vsz . 135.It Fl N 136Extract the name list from the specified system instead of the default 137.Dq Pa /netbsd . 138Ignored unless 139.Fl M 140is specified. 141.It Fl O 142Add the information associated with the space or comma separated list 143of keywords specified, after the process 144.Tn ID , 145in the default information 146display. 147Keywords may be appended with an equals 148.Pq Dq = 149sign and a string. 150This causes the printed header to use the specified string instead of 151the standard header. 152.It Fl o 153Display information associated with the space or comma separated list 154of keywords specified. 155Keywords may be appended with an equals 156.Pq Dq = 157sign and a string. 158This causes the printed header to use the specified string instead of 159the standard header. 160.It Fl p 161Display information associated with the specified process 162.Tn ID . 163.It Fl r 164Sort by current CPU usage, instead of by process 165.Tn ID , 166equivalent to 167.Fl k 168.Ar %cpu . 169.It Fl S 170Change the way the process time is calculated by summing all exited 171children to their parent process. 172.It Fl s 173Display one line for each LWP, rather than one line for each process, 174and display information associated with the following keywords: 175uid, pid, ppid, cpu, lid, nlwp, pri, nice, vsz, rss, wchan, lstate, tt, time 176and command. 177.It Fl T 178Display information about processes attached to the device associated 179with the standard input. 180.It Fl t 181Display information about processes attached to the specified terminal 182device. 183Use an question mark 184.Pq Dq \&? 185for processes not attached to a 186terminal device and a minus sign 187.Pq Dq - 188for processes that have 189been revoked from their terminal device. 190.It Fl U 191Displays processes belonging to the user whose username or uid has 192been given to the 193.Fl U 194switch. 195.It Fl u 196Display information associated with the following keywords: 197user, pid, %cpu, %mem, vsz, rss, tt, state, start, time, and command. 198The 199.Fl u 200option implies the 201.Fl r 202option. 203.It Fl v 204Display information associated with the following keywords: 205pid, state, time, sl, re, pagein, vsz, rss, lim, tsiz, 206%cpu, %mem, and command. 207The 208.Fl v 209option implies the 210.Fl m 211option. 212.It Fl W 213Extract swap information from the specified file instead of the 214default 215.Dq Pa /dev/drum . 216Ignored unless 217.Fl M 218is specified. 219.It Fl w 220Use 132 columns to display information, instead of the default which 221is your window size. 222If the 223.Fl w 224option is specified more than once, 225.Nm 226will use as many columns as necessary without regard for your window size. 227.It Fl x 228Also display information about processes without controlling terminals. 229.El 230.Pp 231A complete list of the available keywords are listed below. 232Some of these keywords are further specified as follows: 233.Bl -tag -width indent 234.It %cpu 235The CPU utilization of the process; this is a decaying average over up to 236a minute of previous (real) time. 237Since the time base over which this is computed varies (since processes may 238be very young) it is possible for the sum of all 239.Tn %CPU 240fields to exceed 100%. 241.It %mem 242The percentage of real memory used by this process. 243.It flags 244The flags (in hexadecimal) associated with the process as in 245the include file 246.Aq Pa sys/proc.h : 247.Bl -column P_NOCLDSTOP P_NOCLDSTOP 248.It Dv "P_ADVLOCK" Ta No "0x00000001 process may hold a POSIX advisory lock" 249.It Dv "P_CONTROLT" Ta No "0x00000002 process has a controlling terminal" 250.It Dv "P_INMEM" Ta No "0x00000004 process is loaded into memory" 251.It Dv "P_NOCLDSTOP" Ta No "0x00000008 no 252.Dv SIGCHLD 253when children stop 254.It Dv "P_PPWAIT" Ta No "0x00000010 parent is waiting for child to exec/exit" 255.It Dv "P_PROFIL" Ta No "0x00000020 process has started profiling" 256.It Dv "P_SELECT" Ta No "0x00000040 selecting; wakeup/waiting danger" 257.It Dv "P_SINTR" Ta No "0x00000080 sleep is interruptible" 258.It Dv "P_SUGID" Ta No "0x00000100 process had set id privileges since last exec" 259.It Dv "P_SYSTEM" Ta No "0x00000200 system process: no sigs, stats or swapping" 260.It Dv "P_TIMEOUT" Ta No "0x00000400 timing out during sleep" 261.It Dv "P_TRACED" Ta No "0x00000800 process is being traced" 262.It Dv "P_WAITED" Ta No "0x00001000 debugging process has waited for child" 263.It Dv "P_WEXIT" Ta No "0x00002000 working on exiting" 264.It Dv "P_EXEC" Ta No "0x00004000 process called" 265.Xr execve 2 266.It Dv "P_OWEUPC" Ta No "0x00008000 owe process an addupc() call at next ast" 267.\" the routine addupc is not documented in the man pages 268.It Dv "P_FSTRACE" Ta No "0x00010000 tracing via file system" 269.It Dv "P_NOCLDWAIT" Ta No "0x00020000 no zombies when children die" 270.It Dv "P_32" Ta No "0x00040000 32-bit process (used on 64-bit kernels)" 271.It Dv "P_BIGLOCK" Ta No "0x00080000 process needs kernel ``big lock'' to run" 272.It Dv "P_INEXEC" Ta No "0x00100000 process is exec'ing and cannot be traced" 273.It Dv "P_SYSTRACE" Ta No "0x00200000 process system call tracing active" 274.El 275.It lim 276The soft limit on memory used, specified via a call to 277.Xr setrlimit 2 . 278.It lstart 279The exact time the command started, using the 280.Dq %C 281format described in 282.Xr strftime 3 . 283.It nice 284The process scheduling increment (see 285.Xr setpriority 2 ) . 286.It rss 287the real memory (resident set) size of the process (in 1024 byte units). 288.It start 289The time the command started. 290If the command started less than 24 hours ago, the start time is 291displayed using the 292.Dq %l:%M%p 293format described in 294.Xr strftime 3 . 295If the command started less than 7 days ago, the start time is 296displayed using the 297.Dq %a%p 298format. 299Otherwise, the start time is displayed using the 300.Dq %e%b%y 301format. 302.It state 303The state is given by a sequence of letters, for example, 304.Dq Tn RWNA . 305The first letter indicates the run state of the process: 306.Pp 307.Bl -tag -width indent -compact 308.It D 309Marks a process in disk (or other short term, uninterruptible) wait. 310.It I 311Marks a process that is idle (sleeping for longer than about 20 seconds). 312.It R 313Marks a runnable process. 314.It S 315Marks a process that is sleeping for less than about 20 seconds. 316.It T 317Marks a stopped process. 318.It Z 319Marks a dead process (a 320.Dq zombie ) . 321.El 322.Pp 323Additional characters after these, if any, indicate additional state 324information: 325.Pp 326.Bl -tag -width indent -compact 327.It + 328The process is in the foreground process group of its control terminal. 329.It - 330The LWP is detached (can't be waited for). 331.It \*[Lt] 332The process has raised 333.Tn CPU 334scheduling priority. 335.It \*[Gt] 336The process has specified a soft limit on memory requirements and is 337currently exceeding that limit; such a process is (necessarily) not 338swapped. 339.It A 340the process has asked for random page replacement 341.Pf ( Dv VA_ANOM , 342from 343.Xr madvise 2 , 344for example, a LISP interpreter in a garbage collect). 345.It a 346The process is using scheduler activations. 347.It E 348The process is trying to exit. 349.It K 350The process is a kernel thread or system process. 351.It L 352The process has pages locked in core (for example, for raw 353.Tn I/O ) . 354.It l 355The process has multiple LWPs. 356.It N 357The process has reduced 358.Tn CPU 359scheduling priority (see 360.Xr setpriority 2 ) . 361.It S 362The process has asked for 363.Tn FIFO 364page replacement 365.Pf ( Dv VA_SEQL , 366from 367.Xr madvise 2 , 368for example, a large image processing program using virtual memory to 369sequentially address voluminous data). 370.It s 371The process is a session leader. 372.It V 373The process is suspended during a 374.Xr vfork 2 . 375.It W 376The process is swapped out. 377.It X 378The process is being traced or debugged. 379.It x 380The process is running under 381.Xr systrace 1 . 382.El 383.It tt 384An abbreviation for the pathname of the controlling terminal, if any. 385The abbreviation consists of the two letters following 386.Dq Pa /dev/tty , 387or, for the console, 388.Dq co . 389This is followed by a 390.Dq \&- 391if the process can no longer reach that 392controlling terminal (i.e., it has been revoked). 393.It wchan 394The event (an address in the system) on which a process waits. 395When printed numerically, the initial part of the address is 396trimmed off and the result is printed in hex, for example, 0x80324000 prints 397as 324000. 398.El 399.Pp 400When printing using the command keyword, a process that has exited and 401has a parent that has not yet waited for the process (in other words, a zombie) 402is listed as 403.Dq Aq defunct , 404and a process which is blocked while trying to exit is listed as 405.Dq Aq exiting . 406.Pp 407.Nm 408will try to locate the processes' argument vector from the user 409area in order to print the command name and arguments. 410This method is not reliable because a process is allowed to destroy this 411information. 412The ucomm (accounting) keyword will always contain 413the real command name as contained in the process structure's p_comm field. 414.Pp 415If the command vector cannot be located (usually because it has not 416been set, as is the case of system processes and/or kernel threads) 417the command name is printed within square brackets. 418.Pp 419To indicate that the argument vector has been tampered with, 420.Nm 421will append the real command name to the output within parentheses 422if the basename of the first argument in the argument vector 423does not match the contents of the real command name. 424.Pp 425In addition, 426.Nm 427checks for the following two situations and does not append the 428real command name parenthesized: 429.Bl -tag -width indent 430.It -shellname 431The login process traditionally adds a 432.Sq - 433in front of the shell name to indicate a login shell. 434.Nm 435will not append parenthesized the command name if it matches with 436the name in the first argument of the argument vector, skipping 437the leading 438.Sq - . 439.It daemonname: current-activity 440Daemon processes frequently report their current activity by setting 441their name to be like 442.Dq daemonname: current-activity . 443.Nm 444will not append parenthesized the command name, if the string preceding the 445.Sq \&: 446in the first argument of the argument vector matches the command name. 447.El 448.Sh KEYWORDS 449The following is a complete list of the available keywords and their 450meanings. 451Several of them have aliases (keywords which are synonyms). 452.Pp 453.Bl -tag -width groupnames -compact 454.It %cpu 455percentage CPU usage (alias pcpu) 456.It %mem 457percentage memory usage (alias pmem) 458.It acflag 459accounting flag (alias acflg) 460.It comm 461command (the argv[0] value) 462.It command 463command and arguments (alias args) 464.It cpu 465short-term CPU usage factor (for scheduling) 466.It ctime 467accumulated CPU time of all children that have exited 468.It egid 469effective group id 470.It egroup 471group name (from egid) 472.It etime 473elapsed time since the process was started, in the form 474.Li [[dd-]hh:]mm:ss 475.It euid 476effective user id 477.It euser 478user name (from euid) 479.It flags 480the process flags, in hexadecimal (alias f) 481.It gid 482effective group id 483.It group 484group name (from gid) 485.It groups 486group access list 487.It groupnames 488group names (from group access list) 489.It holdcnt 490number of holds on the process (if non-zero, process can't be swapped) 491.It inblk 492total blocks read (alias inblock) 493.It jobc 494job control count 495.It ktrace 496tracing flags 497.It ktracep 498tracing vnode 499.It laddr 500kernel virtual address of a 501.Tn "struct lwp" 502belonging to the process. 503.It lid 504ID of the LWP 505.It lim 506memory use limit 507.It logname 508login name of user who started the process (alias login) 509.It lstart 510time started 511.It lstate 512symbolic LWP state 513.It majflt 514total page faults 515.It minflt 516total page reclaims 517.It msgrcv 518total messages received (reads from pipes/sockets) 519.It msgsnd 520total messages sent (writes on pipes/sockets) 521.It nice 522nice value (alias ni) 523.It nivcsw 524total involuntary context switches 525.It nlwp 526number of LWPs in the process 527.It nsigs 528total signals taken (alias nsignals) 529.It nswap 530total swaps in/out 531.It nvcsw 532total voluntary context switches 533.It nwchan 534wait channel (as an address) 535.It oublk 536total blocks written (alias oublock) 537.It p_ru 538resource usage pointer (valid only for zombie) 539.It paddr 540kernel virtual address of the 541.Tn "struct proc" 542belonging to the process. 543.It pagein 544pageins (same as majflt) 545.It pgid 546process group number 547.It pid 548process 549.Tn ID 550.It ppid 551parent process 552.Tn ID 553.It pri 554scheduling priority 555.It re 556core residency time (in seconds; 127 = infinity) 557.It rgid 558real group 559.Tn ID 560.It rlink 561reverse link on run queue, or 0 562.It rlwp 563Number of LWPs on a processor or run queue 564.It rss 565resident set size 566.It rsz 567resident set size + (text size / text use count) (alias rssize) 568.It ruid 569real user 570.Tn ID 571.It ruser 572user name (from ruid) 573.It sess 574session pointer 575.It sid 576session 577.Tn ID 578.It sig 579pending signals (alias pending) 580.It sigcatch 581caught signals (alias caught) 582.It sigignore 583ignored signals (alias ignored) 584.It sigmask 585blocked signals (alias blocked) 586.It sl 587sleep time (in seconds; 127 = infinity) 588.It start 589time started 590.It state 591symbolic process state (alias stat) 592.It stime 593accumulated system CPU time 594.It svgid 595saved gid from a setgid executable 596.It svgroup 597group name (from svgid) 598.It svuid 599saved uid from a setuid executable 600.It svuser 601user name (from svuid) 602.It tdev 603control terminal device number 604.It time 605accumulated CPU time, user + system (alias cputime) 606.It tpgid 607control terminal process group 608.Tn ID 609.It tsess 610control terminal session pointer 611.It tsiz 612text size (in Kbytes) 613.It tt 614control terminal name (two letter abbreviation) 615.It tty 616full name of control terminal 617.It ucomm 618name to be used for accounting 619.It uid 620effective user 621.Tn ID 622.It upr 623scheduling priority on return from system call (alias usrpri) 624.It user 625user name (from uid) 626.It utime 627accumulated user CPU time 628.It vsz 629virtual size in Kbytes (alias vsize) 630.It wchan 631wait channel (as a symbolic name) 632.It xstat 633exit or stop status (valid only for stopped or zombie process) 634.El 635.Sh FILES 636.Bl -tag -width /var/run/kvm.db -compact 637.It Pa /dev 638special files and device names 639.It Pa /dev/drum 640default swap device 641.It Pa /var/run/dev.db 642/dev name database 643.It Pa /var/db/kvm.db 644system namelist database 645.It Pa /netbsd 646default system namelist 647.El 648.Sh SEE ALSO 649.Xr kill 1 , 650.Xr pgrep 1 , 651.Xr pkill 1 , 652.Xr sh 1 , 653.Xr systrace 1 , 654.Xr w 1 , 655.Xr kvm 3 , 656.Xr strftime 3 , 657.Xr dev_mkdb 8 , 658.Xr pstat 8 659.Sh BUGS 660Since 661.Nm 662cannot run faster than the system and is run as any other scheduled 663process, the information it displays can never be exact. 664