| PS(1) | General Commands Manual | PS(1) |
ps — display
process status
ps |
[[-]AacefHhjkLlmrSTuvwx]
[-M core]
[-N system]
[-O fmt]
[-o fmt]
[-p pid]
[-t tty]
[-U user]
[-W swap] |
The ps utility displays information about
active processes. When given no options, ps prints
information about processes of the current user that have a controlling
terminal.
The information displayed is selected based on a set of keywords
(and for even more control, see the -L,
-O, and -o options). The
default output format includes, for each process, the process's ID,
controlling terminal, state, CPU time (including both user and system time),
and associated command.
The options are as follows:
-A-a-c-e-f-m and -r options
are also used, they control how sibling processes are sorted relative to
each other.-H-h-j-k-L-l-M
core-m-N
system-O
fmt-o
fmt-p
pid-r-S-T-t
tty-U
user-u-u option implies the -r
option.-v-v option implies the -m
option.-W
swap-w-w option is specified
more than once, ps will use as many columns as
necessary without regard for window size.-xThe following is a complete list of the available keywords and their meanings. Several of them have aliases, which are also noted.
%cpupcpu. The CPU utilization of the process;
this is a decaying average over up to a minute of previous (real) time.
Since the time base over which this is computed varies (since processes
may be very young), it is possible for the sum of all
%cpu fields to exceed 100%.%mempmem. The percentage of real memory used by
this process.acflagacflg. Accounting flag.commandargs. Command and arguments.cpucpuidcwddsizetimeflagsf. The thread flags (in hexadecimal), as
defined in the include file
<sys/proc.h>:
P_INKTR 0x1 writing ktrace(2) record
P_PROFPEND 0x2 this thread needs SIGPROF
P_ALRMPEND 0x4 this thread needs SIGVTALRM
P_SIGSUSPEND 0x8 need to restore before-suspend mask
P_CANTSLEEP 0x10 this thread is not permitted to sleep
P_SINTR 0x80 sleep is interruptible
P_SYSTEM 0x200 system process: no sigs, stats, or
swapping
P_TIMEOUT 0x400 timing out during sleep
P_WEXIT 0x2000 working on exiting
P_OWEUPC 0x8000 profiling sample needs recording
P_SUSPSINGLE 0x80000 need to suspend for single threading
P_THREAD 0x4000000 not the original thread
P_SUSPSIG 0x8000000 stopped because of a signal
P_CPUPEG 0x40000000 do not move to another cpu
gidgroupinblkinblock. Total blocks read.jobcktracektraceplimlognamelogin. Login name of user who started the
process.lstartmajfltmaxrssminfltmsgrcvmsgsndniceni. The process scheduling increment (see
setpriority(2)).nivcswnsigsnsignals. Total signals taken.nswapnvcswnwchanoublkoublock. Total blocks written.p_rupaddrpageinmajflt).pgidpidpledgeppidpriprocflags<sys/proc.h>:
PS_CONTROLT 0x1 process has a controlling
terminal
PS_EXEC 0x2 process called exec(3)
PS_INEXEC 0x4 process is doing an exec right
now
PS_EXITING 0x8 process is exiting
PS_SUGID 0x10 process had set ID privileges
since last exec
PS_SUGIDEXEC 0x20 last exec(3) was set[ug]id
PS_PPWAIT 0x40 parent is waiting for process
to exec/exit
PS_ISPWAIT 0x80 process is parent of PPWAIT
child
PS_PROFIL 0x100 process has started profiling
PS_TRACED 0x200 process is being traced
PS_WAITED 0x400 debugging process has waited
for child
PS_COREDUMP 0x800 busy coredumping
PS_SINGLEEXIT 0x1000 other threads must die
PS_SINGLEUNWIND 0x2000 other threads must unwind
PS_NOZOMBIE 0x4000 pid 1 waits for me instead of
dad
PS_STOPPING 0x8000 just stopped, need to send
SIGCHLD
PS_SYSTEM 0x10000 No signals, stats or swapping
PS_EMBRYO 0x20000 New process, not yet fledged
PS_ZOMBIE 0x40000 Dead and ready to be waited for
PS_NOBROADCASTKILL 0x80000 Process excluded from kill -1
PS_PLEDGE 0x100000 process has called pledge(2)
PS_WXNEEDED 0x00200000 process allowed to violate W^X
PS_EXECPLEDGE 0x00400000 has exec pledges
PS_ORPHAN 0x00800000 process is on an orphan list
PS_CHROOT 0x01000000 process is chrooted
PS_NOBTCFI 0x02000000 no Branch Target CFI
PS_CONTINUED 0x20000000 process continued from stopped state
but has not been waited for yet
PS_STOPPED 0x40000000 process is in stopped state
rergidrgrouprlinkrssrszrssize. Resident set size + (text size /
text use count).rtableruidruserruid).sesssigpending. Pending signals.sigcatchcaught. Caught signals.sigignoreignored. Ignored signals.sigmaskblocked. Blocked signals.slssizstartstatestat. The state is given by a sequence of
letters, for example, “RWN”. The first letter indicates the
run state of the process:
Additional characters after these, if any, indicate additional state information:
supgidsupgrpsvgidsvuidtdevtid-H.timecputime. Accumulated CPU time, user +
system.tpgidtsesstsizttttyucommcomm. Name to be used for accounting.uiduprusrpri. Scheduling priority on return from
system call.useruid).vszvsize. Virtual size, in Kilobytes.wchanxstatThe following environment variables affect the execution of
ps:
COLUMNSps defaults to the terminal
width minus 1. If none of stdout,
stderr, and stdin are a
terminal, 79 columns are used.LC_CTYPETZThe ps utility exits 0 on success,
and >0 if an error occurs.
Display information on all system processes:
$ ps -auxwfstat(1), kill(1), netstat(1), pgrep(1), pkill(1), procmap(1), systat(1), top(1), w(1), kvm(3), strftime(3), dev_mkdb(8), iostat(8), pstat(8), vmstat(8)
The ps utility is compliant with the
IEEE Std 1003.1-2008 (“POSIX.1”)
specification, except that the flag [-G] is
unsupported and the flags [-ptU] support only single
arguments, not lists.
The flags [-defglnu] are marked by
IEEE Std 1003.1-2008 (“POSIX.1”) as
being an X/Open System Interfaces option. Of these,
[-dfgn] are not supported by this implementation of
ps; behaviour for the flags
[-elu] differs between this implementation and the
X/Open System Interfaces option of IEEE Std 1003.1-2008
(“POSIX.1”).
The flags [-cfHhjkLMmNOrSTvWwx] are
extensions to IEEE Std 1003.1-2008
(“POSIX.1”).
Only the following keywords are recognised by
IEEE Std 1003.1-2008 (“POSIX.1”):
args, comm,
etime, group,
nice, pcpu,
pgid, pid,
ppid, rgroup,
ruser, time,
tty, user, and
vsz.
A ps command first appeared in
Version 3 AT&T UNIX.
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⟩”.
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, so the names cannot be
depended on too much. The ucomm (accounting) keyword
can, however, be depended on.
The information displayed is only a snapshot of a constantly changing system.
| October 15, 2024 | openbsd |