PS(1) | MidnightBSD General Commands Manual | PS(1) |
ps
— process
status
ps |
[--libxo ]
[-aCcdefHhjlmrSTuvwXxZ ]
[-O fmt |
-o fmt]
[-G
gid[,gid...]]
[-J
jid[,jid...]]
[-M core]
[-N system]
[-p
pid[,pid...]]
[-t
tty[,tty...]]
[-U
user[,user...]] |
ps |
[--libxo ] [-L ] |
The ps
utility displays a header line,
followed by lines containing information about all of your processes that
have controlling terminals. If the -x
options is
specified, ps
will also display processes that do
not have controlling terminals.
A different set of processes can be selected for display by using
any combination of the -a
,
-G
, -J
,
-p
, -T
,
-t
, and -U
options. If more
than one of these options are given, then ps
will
select all processes which are matched by at least one of the given
options.
For the processes which have been selected for display,
ps
will usually display one line per process. The
-H
option may result in multiple output lines (one
line per thread) for some processes. By default all of these output lines
are sorted first by controlling terminal, then by process ID. The
-m
, -r
,
-u
, and -v
options will
change the sort order. If more than one sorting option was given, then the
selected processes will be sorted by the last sorting option which was
specified.
For the processes which have been selected for display, the
information to display is selected based on a set of keywords (see the
-L
, -O
, and
-o
options). The default output format includes, for
each process, the process' ID, controlling terminal, state, CPU time
(including both user and system time) and associated command.
If the ps
process is associated with a
terminal, the default output width is that of the terminal; otherwise the
output width is unlimited. See also the -w
option.
The options are as follows:
--libxo
-a
-c
-C
-d
-m
and -r
options are also used, they control how sibling processes are sorted
relative to each other. Note that this option has no effect if the
“command” column is not the last column displayed.-e
-f
-G
-H
-h
-j
user
, pid
,
ppid
, pgid
,
sid
, jobc
,
state
, tt
,
time
, and command
.-J
jid
or
name
of the jail. Use -J
0 to display
only host processes. This flag implies -x
by
default.-L
-O
and
-o
options.-l
uid
, pid
,
ppid
, cpu
,
pri
, nice
,
vsz
, rss
,
mwchan
, state
,
tt
, time
, and
command
.-M
-m
-N
-O
=
’) sign and a string. This causes
the printed header to use the specified string instead of the standard
header.-o
=
’) sign and a string that
spans the rest of the argument, and can contain space and comma
characters. This causes the printed header to use the specified string
instead of the standard header. Multiple keywords may also be given in the
form of more than one -o
option. So the header
texts for multiple keywords can be changed. If all keywords have empty
header texts, no header line is written.-p
-r
-S
-T
-t
tt
keyword) can be specified.-U
-u
user
, pid
,
%cpu
, %mem
,
vsz
, rss
,
tt
, state
,
start
, time
, and
command
. The -u
option
implies the -r
option.-v
pid
, state
,
time
, sl
,
re
, pagein
,
vsz
, rss
,
lim
, tsiz
,
%cpu
, %mem
, and
command
. The -v
option
implies the -m
option.-w
ps
is associated with
a terminal. If the -w
option is specified more
than once, ps
will use as many columns as
necessary without regard for the window size. Note that this option has no
effect if the “command” column is not the last column
displayed.-X
-x
-X
option. If both -X
and
-x
are specified in the same command, then
ps
will use the one which was specified last.-Z
ps
will display
information.A complete list of the available keywords are listed below. Some of these keywords are further specified as follows:
%cpu
%cpu
fields to exceed 100%.%mem
class
flags
<sys/proc.h>
:
P_ADVLOCK |
0x00001 | Process may hold a POSIX advisory lock |
P_CONTROLT |
0x00002 | Has a controlling terminal |
P_KPROC |
0x00004 | Kernel process |
P_PPWAIT |
0x00010 | Parent is waiting for child to exec/exit |
P_PROFIL |
0x00020 | Has started profiling |
P_STOPPROF |
0x00040 | Has thread in requesting to stop prof |
P_HADTHREADS |
0x00080 | Has had threads (no cleanup shortcuts) |
P_SUGID |
0x00100 | Had set id privileges since last exec |
P_SYSTEM |
0x00200 | System proc: no sigs, stats or swapping |
P_SINGLE_EXIT |
0x00400 | Threads suspending should exit, not wait |
P_TRACED |
0x00800 | Debugged process being traced |
P_WAITED |
0x01000 | Someone is waiting for us |
P_WEXIT |
0x02000 | Working on exiting |
P_EXEC |
0x04000 | Process called exec |
P_WKILLED |
0x08000 | Killed, shall go to kernel/user boundary ASAP |
P_CONTINUED |
0x10000 | Proc has continued from a stopped state |
P_STOPPED_SIG |
0x20000 | Stopped due to SIGSTOP/SIGTSTP |
P_STOPPED_TRACE |
0x40000 | Stopped because of tracing |
P_STOPPED_SINGLE |
0x80000 | Only one thread can continue |
P_PROTECTED |
0x100000 | Do not kill on memory overcommit |
P_SIGEVENT |
0x200000 | Process pending signals changed |
P_SINGLE_BOUNDARY |
0x400000 | Threads should suspend at user boundary |
P_HWPMC |
0x800000 | Process is using HWPMCs |
P_JAILED |
0x1000000 | Process is in jail |
P_TOTAL_STOP |
0x2000000 | Stopped for system suspend |
P_INEXEC |
0x4000000 | Process is in execve(2) |
P_STATCHILD |
0x8000000 | Child process stopped or exited |
P_INMEM |
0x10000000 | Loaded into memory |
P_SWAPPINGOUT |
0x20000000 | Process is being swapped out |
P_SWAPPINGIN |
0x40000000 | Process is being swapped in |
P_PPTRACE |
0x80000000 | Vforked child issued ptrace(PT_TRACEME) |
flags2
<sys/proc.h>
:
P2_INHERIT_PROTECTED |
0x00000001 | New children get P_PROTECTED |
P2_NOTRACE |
0x00000002 | No ptrace(2) attach or coredumps |
P2_NOTRACE_EXEC |
0x00000004 | Keep P2_NOPTRACE on execve(2) |
P2_AST_SU |
0x00000008 | Handles SU ast for kthreads |
P2_PTRACE_FSTP |
0x00000010 | SIGSTOP from PT_ATTACH not yet handled |
label
lim
lstart
%c
’ format described in
strftime(3).lockname
logname
mwchan
nice
rss
start
%H:%M
” format described in
strftime(3). If the
command started less than 7 days ago, the start time is displayed using
the “%a%H
” format. Otherwise, the
start time is displayed using the
“%e%b%y
” format.state
RWNA
”. The first character
indicates the run state of the process:
D
I
L
R
S
T
W
Z
Additional characters after these, if any, indicate additional state information:
+
<
C
E
J
L
N
s
V
W
X
tt
-
’ if the process can no
longer reach that controlling terminal (i.e., it has been revoked). A
‘-
’ without a preceding two letter
abbreviation or pseudo-terminal device number indicates a process which
never had a controlling terminal. The full pathname of the controlling
terminal is available via the tty
keyword.wchan
When printing using the command keyword, a process that has exited
and has a parent that has not yet waited for the process (in other words, a
zombie) is listed as
“<defunct>
”, and a process which
is blocked while trying to exit is listed as
“<exiting>
”. If the arguments
cannot be located (usually because it has not been set, as is the case of
system processes and/or kernel threads) the command name is printed within
square brackets. The ps
utility first tries to
obtain the arguments cached by the kernel (if they were shorter than the
value of the kern.ps_arg_cache_limit sysctl). The
process can change the arguments shown with
setproctitle(3).
Otherwise, ps
makes an educated guess as to the file
name and arguments given when the process was created by examining memory or
the swap area. The method is inherently somewhat unreliable and in any event
a process is entitled to destroy this information. The ucomm (accounting)
keyword can, however, be depended on. If the arguments are unavailable or do
not agree with the ucomm keyword, the value for the ucomm keyword is
appended to the arguments in parentheses.
The following is a complete list of the available keywords and their meanings. Several of them have aliases (keywords which are synonyms).
%cpu
pcpu
)%mem
pmem
)acflag
acflg
)args
class
comm
command
cow
cpu
dsiz
emul
etime
etimes
fib
flags
f
)flags2
f2
)gid
egid
)group
egroup
)inblk
inblock
)jail
jid
jobc
ktrace
label
lim
lockname
logname
lstart
lwp
tid
)majflt
minflt
msgrcv
msgsnd
mwchan
nice
ni
)nivcsw
nlwp
nsigs
nsignals
)nswap
nvcsw
nwchan
oublk
oublock
)paddr
pagein
pgid
pid
ppid
pri
re
rgid
rgroup
rss
rtprio
ruid
ruser
sid
sig
pending
)sigcatch
caught
)sigignore
ignored
)sigmask
blocked
)sl
ssiz
start
state
stat
)svgid
svuid
systime
tdaddr
tdname
tdev
time
cputime
)tpgid
tracer
tsid
tsiz
tt
tty
ucomm
uid
euid
)upr
usrpri
)uprocp
user
usertime
vmaddr
vsz
vsize
)wchan
xstat
Note that the pending
column displays
bitmask of signals pending in the process queue when
-H
option is not specified, otherwise the per-thread
queue of pending signals is shown.
The following environment variables affect the execution of
ps
:
COLUMNS
ps
attempts to automatically determine
the terminal width.The ps
utility exits 0 on success,
and >0 if an error occurs.
Display information on all system processes:
$ ps -auxw
kill(1), pgrep(1), pkill(1), procstat(1), w(1), kvm(3), libxo(3), strftime(3), xo_parse_args(3), mac(4), procfs(5), pstat(8), sysctl(8), mutex(9)
For historical reasons, the ps
utility
under FreeBSD supports a different set of options
from what is described by IEEE Std 1003.2
(“POSIX.2”), and what is supported on
non-BSD operating
systems.
The ps
command appeared in
Version 3 AT&T UNIX in section 8 of the
manual.
Since ps
cannot run faster than the system
and is run as any other scheduled process, the information it displays can
never be exact.
The ps
utility does not correctly display
argument lists containing multibyte characters.
June 27, 2020 | midnightbsd-3.1 |