xref: /openbsd/bin/ps/ps.1 (revision 264ca280)
1.\"	$OpenBSD: ps.1,v 1.106 2016/04/25 20:34:55 jmc Exp $
2.\"	$NetBSD: ps.1,v 1.16 1996/03/21 01:36:28 jtc Exp $
3.\"
4.\" Copyright (c) 1980, 1990, 1991, 1993, 1994
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"     @(#)ps.1	8.3 (Berkeley) 4/18/94
32.\"
33.Dd $Mdocdate: April 25 2016 $
34.Dt PS 1
35.Os
36.Sh NAME
37.Nm ps
38.Nd display process status
39.Sh SYNOPSIS
40.Nm ps
41.Sm off
42.Op Fl AaceHhjkLlmrSTuvwx
43.Sm on
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.Op Fl U Ar username
51.Op Fl W Ar swap
52.Sh DESCRIPTION
53The
54.Nm
55utility displays information about active processes.
56When given no options,
57.Nm
58prints information about processes of the current user that have a
59controlling terminal.
60.Pp
61The information displayed is selected based on a set of keywords (and for
62even more control, see the
63.Fl L ,
64.Fl O ,
65and
66.Fl o
67options).
68The default output format includes, for each process, the process's ID,
69controlling terminal, state, CPU time (including both user and system time),
70and associated command.
71.Pp
72The options are as follows:
73.Bl -tag -width Ds
74.It Fl A
75Display information about processes for all users, including those without controlling
76terminals.
77.It Fl a
78Display information about processes for all users with controlling terminals.
79.It Fl c
80Do not display full command with arguments, but only the
81executable name.
82This may be somewhat confusing; for example, all
83.Xr sh 1
84scripts will show as
85.Dq sh .
86.It Fl e
87Display the environment as well.
88.It Fl H
89Also display information about kernel visible threads.
90.It Fl h
91Repeat the information header as often as necessary to guarantee one
92header per page of information.
93.It Fl j
94Print information associated with the following keywords:
95user, pid, ppid, pgid, sess, jobc, state, tt, time, and command.
96.It Fl k
97Also display information about kernel threads.
98.It Fl L
99List the set of available keywords.
100This option should not be specified with other options.
101.It Fl l
102Display information associated with the following keywords:
103uid, pid, ppid, cpu, pri, nice, vsz, rss, wchan, state, tt, time,
104and command.
105.It Fl M Ar core
106Extract values associated with the name list from the specified core
107instead of the running kernel.
108.It Fl m
109Sort by memory usage, instead of by start time ID.
110.It Fl N Ar system
111Extract the name list from the specified system instead of the running kernel.
112.It Fl O Ar fmt
113Add the information associated with the space or comma separated list
114of keywords specified, after the process ID,
115in the default information
116display.
117Keywords may be appended with an equals sign
118.Pq Sq =
119and a string.
120This causes the printed header to use the specified string instead of
121the standard header.
122.It Fl o Ar fmt
123Display information associated with the space or comma separated list
124of keywords specified.
125Keywords may be appended with an equals sign
126.Pq Sq =
127and a string.
128This causes the printed header to use the specified string instead of
129the standard header.
130.It Fl p Ar pid
131Display information associated with the specified process ID.
132.It Fl r
133Sort by current CPU usage, instead of by start time ID.
134.It Fl S
135Change the way the process time is calculated by summing all exited
136children to their parent process.
137.It Fl T
138Display information about processes attached to the device associated
139with the standard input.
140.It Fl t Ar tty
141Display information about processes attached to the specified terminal
142device.
143.It Fl U Ar username
144Display the processes belonging to the specified
145.Ar username .
146.It Fl u
147Display information associated with the following keywords:
148user, pid, %cpu, %mem, vsz, rss, tt, state, start, time, and command.
149The
150.Fl u
151option implies the
152.Fl r
153option.
154.It Fl v
155Display information associated with the following keywords:
156pid, state, time, sl, re, pagein, vsz, rss, lim, tsiz,
157%cpu, %mem, and command.
158The
159.Fl v
160option implies the
161.Fl m
162option.
163.It Fl W Ar swap
164When not using the running kernel,
165extract swap information from the specified file.
166.It Fl w
167Use 132 columns to display information, instead of the default, which
168is the window size.
169If the
170.Fl w
171option is specified more than once,
172.Nm
173will use as many columns as necessary without regard for window size.
174.It Fl x
175Display information about processes without controlling terminals.
176.El
177.Sh KEYWORDS
178The following is a complete list of the available keywords
179and their meanings.
180Several of them have aliases,
181which are also noted.
182.Bl -tag -width "sigignoreXX" -offset 3n
183.It Cm %cpu
184Alias:
185.Cm pcpu .
186The CPU utilization of the process; this is a decaying average over up to
187a minute of previous (real) time.
188Since the time base over which this is computed varies (since processes may
189be very young) it is possible for the sum of all
190.Cm %cpu
191fields to exceed 100%.
192.It Cm %mem
193Alias:
194.Cm pmem .
195The percentage of real memory used by this process.
196.It Cm acflag
197Alias:
198.Cm acflg .
199Accounting flag.
200.It Cm command
201Alias:
202.Cm args .
203Command and arguments.
204.It Cm cpu
205Short-term CPU usage factor (for scheduling).
206.It Cm cpuid
207CPU ID (zero on single processor systems).
208.It Cm cwd
209Current working directory.
210.It Cm dsiz
211Data size, in Kilobytes.
212.It Cm emul
213Name of system call emulation environment.
214.It Cm flags
215Alias:
216.Cm f .
217The thread flags (in hexadecimal), as defined in the include file
218.In sys/proc.h :
219.Bd -literal
220P_INKTR           0x1 writing ktrace(2) record
221P_PROFPEND        0x2 this thread needs SIGPROF
222P_ALRMPEND        0x4 this thread needs SIGVTALRM
223P_SIGSUSPEND      0x8 need to restore before-suspend mask
224P_CANTSLEEP      0x10 this thread is not permitted to sleep
225P_SELECT         0x40 selecting; wakeup/waiting danger
226P_SINTR          0x80 sleep is interruptible
227P_SYSTEM        0x200 system process: no sigs, stats, or
228                      swapping
229P_TIMEOUT       0x400 timing out during sleep
230P_WEXIT        0x2000 working on exiting
231P_OWEUPC       0x8000 profiling sample needs recording
232P_SUSPSINGLE  0x80000 need to suspend for single threading
233P_CONTINUED  0x800000 thread has continued after a stop
234P_THREAD    0x4000000 not the original thread
235P_SUSPSIG   0x8000000 stopped because of a signal
236P_SOFTDEP  0x10000000 stuck processing softdep worklist
237P_CPUPEG   0x40000000 do not move to another cpu
238.Ed
239.It Cm gid
240Effective group.
241.It Cm group
242Text name of effective group ID.
243.It Cm inblk
244Alias:
245.Cm inblock .
246Total blocks read.
247.It Cm jobc
248Job control count.
249.It Cm ktrace
250Tracing flags.
251.It Cm ktracep
252Tracing vnode.
253.It Cm lim
254The soft limit on memory used, specified via a call to
255.Xr setrlimit 2 .
256.It Cm logname
257Alias:
258.Cm login .
259Login name of user who started the process.
260.It Cm lstart
261The exact time the command started, using the
262.Dq %c
263format described in
264.Xr strftime 3 .
265.It Cm majflt
266Total page faults.
267.It Cm maxrss
268Maximum resident set size (in 1024 byte units).
269.It Cm minflt
270Total page reclaims.
271.It Cm msgrcv
272Total messages received (reads from pipes/sockets).
273.It Cm msgsnd
274Total messages sent (writes on pipes/sockets).
275.It Cm nice
276Alias:
277.Cm ni .
278The process scheduling increment (see
279.Xr setpriority 2 ) .
280.It Cm nivcsw
281Total involuntary context switches.
282.It Cm nsigs
283Alias:
284.Cm nsignals .
285Total signals taken.
286.It Cm nswap
287Total swaps in/out.
288.It Cm nvcsw
289Total voluntary context switches.
290.It Cm nwchan
291Wait channel (as an address).
292.It Cm oublk
293Alias:
294.Cm oublock .
295Total blocks written.
296.It Cm p_ru
297Resource usage (valid only for zombie processes).
298.It Cm paddr
299Swap address.
300.It Cm pagein
301Pageins (same as
302.Cm majflt ) .
303.It Cm pgid
304Process group number.
305.It Cm pid
306Process ID.
307.It Cm ppid
308Parent process ID.
309.It Cm pri
310Scheduling priority.
311.It Cm procflags
312The process flags (in hexadecimal), as defined in the include file
313.In sys/proc.h :
314.Bd -literal
315PS_CONTROLT            0x1 process has a controlling
316                           terminal
317PS_EXEC                0x2 process called exec(3)
318PS_INEXEC              0x4 process is doing an exec right
319                           now
320PS_EXITING             0x8 process is exiting
321PS_SUGID              0x10 process had set ID privileges
322                           since last exec
323PS_SUGIDEXEC          0x20 last exec(3) was set[ug]id
324PS_PPWAIT             0x40 parent is waiting for process
325                           to exec/exit
326PS_ISPWAIT            0x80 process is parent of PPWAIT
327                           child
328PS_PROFIL            0x100 process has started profiling
329PS_TRACED            0x200 process is being traced
330PS_WAITED            0x400 debugging process has waited
331                           for child
332PS_COREDUMP          0x800 busy coredumping
333PS_SINGLEEXIT       0x1000 other threads must die
334PS_SINGLEUNWIND     0x2000 other threads must unwind
335PS_NOZOMBIE         0x4000 pid 1 waits for me instead of
336                           dad
337PS_STOPPED          0x8000 just stopped, need to send
338                           SIGCHLD
339PS_SYSTEM          0x10000 No signals, stats or swapping
340PS_EMBRYO          0x20000 New process, not yet fledged
341PS_ZOMBIE          0x40000 Dead and ready to be waited for
342PS_NOBROADCASTKILL 0x80000 Process excluded from kill -1
343PS_PLEDGE         0x100000 process has called pledge(2)
344.Ed
345.It Cm re
346Core residency time (in seconds; 127 = infinity).
347.It Cm rgid
348Real group ID.
349.It Cm rgroup
350Text name of real group ID.
351.It Cm rlink
352Reverse link on run queue, or 0.
353.It Cm rss
354The real memory (resident set) size of the process (in 1024 byte units).
355.It Cm rsz
356Alias:
357.Cm rssize .
358Resident set size + (text size / text use count).
359.It Cm rtable
360Routing table.
361.It Cm ruid
362Real user ID.
363.It Cm ruser
364User name (from
365.Cm ruid ) .
366.It Cm sess
367Session pointer.
368.It Cm sig
369Alias:
370.Cm pending .
371Pending signals.
372.It Cm sigcatch
373Alias:
374.Cm caught .
375Caught signals.
376.It Cm sigignore
377Alias:
378.Cm ignored .
379Ignored signals.
380.It Cm sigmask
381Alias:
382.Cm blocked .
383Blocked signals.
384.It Cm sl
385Sleep time (in seconds; 127 = infinity).
386.It Cm ssiz
387Stack size, in Kilobytes.
388.It Cm start
389Alias:
390.Cm etime .
391The time the command started.
392If the command started less than 24 hours ago, the start time is
393displayed using the
394.Dq %l:%M%p
395format described in
396.Xr strftime 3 .
397If the command started less than 7 days ago, the start time is
398displayed using the
399.Dq %a%I%p
400format.
401Otherwise, the start time is displayed using the
402.Dq %e%b%y
403format.
404.It Cm state
405Alias:
406.Cm stat .
407The state is given by a sequence of letters, for example,
408.Dq RWN .
409The first letter indicates the run state of the process:
410.Pp
411.Bl -tag -width indent -compact
412.It D
413Marks a process in disk (or other short term, uninterruptible) wait.
414.It I
415Marks a process that is idle (sleeping for longer than about 20 seconds).
416.It R
417Marks a runnable process.
418.It S
419Marks a process that is sleeping for less than about 20 seconds.
420.It T
421Marks a stopped process.
422.It Z
423Marks a dead process (a
424.Dq zombie ) .
425.El
426.Pp
427Additional characters after these, if any, indicate additional state
428information:
429.Pp
430.Bl -tag -width indent -compact
431.It +
432The process is in the foreground process group of its control terminal.
433.It \*(Lt
434The process has a raised CPU
435scheduling priority (see
436.Xr setpriority 2 ) .
437.It \*(Gt
438The process has specified a soft limit on memory requirements and is
439currently exceeding that limit; such a process is (necessarily) not
440swapped.
441.\" .It A
442.\" the process has asked for random page replacement
443.\" .Pf ( Dv MADV_RANDOM ,
444.\" from
445.\" .Xr madvise 2 ,
446.\" for example,
447.\" .Xr lisp 1
448.\" in a garbage collect).
449.It E
450The process is trying to exit.
451.It K
452The process is a kernel thread.
453.It N
454The process has a reduced CPU
455scheduling priority.
456.It p
457The process has called
458.Xr pledge 2 .
459.\" .It S
460.\" The process has asked for FIFO
461.\" page replacement
462.\" .Pf ( Dv MADV_SEQUENTIAL ,
463.\" from
464.\" .Xr madvise 2 ,
465.\" for example, a large image processing program using virtual memory to
466.\" sequentially address voluminous data).
467.It s
468The process is a session leader.
469.It V
470The process is suspended during a
471.Xr vfork 2 .
472.It X
473The process is being traced or debugged.
474.It / Ns Ar n
475On multiprocessor machines, specifies processor number
476.Ar n .
477.El
478.It Cm svgid
479Saved GID from a setgid executable.
480.It Cm svuid
481Saved UID from a setuid executable.
482.It Cm tdev
483Control terminal device number.
484.It Cm tid
485Thread ID.
486Used together with
487.Fl H .
488.It Cm time
489Alias:
490.Cm cputime .
491Accumulated CPU time, user + system.
492.It Cm tpgid
493Control terminal process group ID.
494.\".It trss
495.\"Text resident set size, in Kilobytes.
496.It Cm tsess
497Control terminal session pointer.
498.It Cm tsiz
499Text size, in Kilobytes.
500.It Cm tt
501An abbreviation for the pathname of the controlling terminal, if any.
502The abbreviation consists of the two letters following
503.Dq /dev/tty ,
504or, for the console,
505.Dq co .
506This is followed by a
507.Sq -
508if the process can no longer reach that
509controlling terminal (i.e. it has been revoked).
510.It Cm tty
511Full name of control terminal.
512.It Cm ucomm
513Alias:
514.Cm comm .
515Name to be used for accounting.
516.It Cm uid
517Effective user ID.
518.It Cm upr
519Alias:
520.Cm usrpri .
521Scheduling priority on return from system call.
522.It Cm user
523User name (from
524.Cm uid ) .
525.It Cm vsz
526Alias:
527.Cm vsize .
528Virtual size, in Kilobytes.
529.It Cm wchan
530The event (an address in the system) on which a process waits.
531When printed numerically, the initial part of the address is
532trimmed off and the result is printed in hex; for example, 0x80324000 prints
533as 324000.
534.It Cm xstat
535Exit or stop status (valid only for stopped or zombie process).
536.El
537.Sh ENVIRONMENT
538The following environment variables affect the execution of
539.Nm :
540.Bl -tag -width "COLUMNS"
541.It Ev COLUMNS
542If set to a positive integer,
543output is formatted to the given width in columns.
544Otherwise,
545.Nm
546defaults to the terminal width \(mi 1, or 79 columns if the output is not a
547terminal.
548.It Ev TZ
549The time zone to use when displaying dates.
550See
551.Xr environ 7
552for more information.
553.El
554.Sh FILES
555.Bl -tag -width "/var/db/kvm_bsd.dbXXX" -compact
556.It Pa /dev
557special files and device names
558.It Pa /var/db/kvm_bsd.db
559system namelist database
560.It Pa /var/run/dev.db
561.Pa /dev
562name database
563.El
564.Sh EXIT STATUS
565.Ex -std ps
566.Sh EXAMPLES
567Display information on all system processes:
568.Pp
569.Dl $ ps -auxw
570.Sh SEE ALSO
571.Xr fstat 1 ,
572.Xr kill 1 ,
573.Xr netstat 1 ,
574.Xr pgrep 1 ,
575.Xr pkill 1 ,
576.Xr procmap 1 ,
577.Xr systat 1 ,
578.Xr top 1 ,
579.Xr w 1 ,
580.Xr kvm 3 ,
581.Xr strftime 3 ,
582.Xr dev_mkdb 8 ,
583.Xr iostat 8 ,
584.Xr pstat 8 ,
585.Xr vmstat 8
586.Sh STANDARDS
587The
588.Nm
589utility is compliant with the
590.St -p1003.1-2008
591specification,
592except that the flag
593.Op Fl G
594is unsupported and
595the flags
596.Op Fl ptU
597support only single arguments, not lists.
598.Pp
599The flags
600.Op Fl defglnu
601are marked by
602.St -p1003.1-2008
603as being an X/Open System Interfaces option.
604Of these,
605.Op Fl dfgn
606are not supported by this implementation of
607.Nm ;
608behaviour for the flags
609.Op Fl elu
610differs between this implementation and the
611X/Open System Interfaces option of
612.St -p1003.1-2008 .
613.Pp
614The flags
615.Op Fl cHhjkLMmNOrSTvWwx
616are extensions to
617.St -p1003.1-2008 .
618.Pp
619Only the following keywords are recognised by
620.St -p1003.1-2008 :
621.Cm args ,
622.Cm comm ,
623.Cm etime ,
624.Cm group ,
625.Cm nice ,
626.Cm pcpu ,
627.Cm pgid ,
628.Cm pid ,
629.Cm ppid ,
630.Cm rgroup ,
631.Cm ruser ,
632.Cm time ,
633.Cm tty ,
634.Cm user ,
635and
636.Cm vsz .
637.Sh HISTORY
638A
639.Nm
640command appeared in
641.At v3
642in section 8 of the manual.
643.Sh CAVEATS
644When printing using the
645.Cm command
646keyword, a process that has exited and
647has a parent that has not yet waited for the process (in other words, a zombie)
648is listed as
649.Dq Aq defunct ,
650and a process which is blocked while trying
651to exit is listed as
652.Dq Aq exiting .
653.Nm
654makes an educated guess as to the file name and arguments given when the
655process was created by examining memory or the swap area.
656The method is inherently somewhat unreliable and in any event a process
657is entitled to destroy this information, so the names cannot be depended
658on too much.
659The
660.Cm ucomm
661(accounting) keyword can, however, be depended on.
662.Sh BUGS
663Since
664.Nm
665cannot run faster than the system and is run as any other scheduled
666process, the information it displays can never be exact.
667