Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ps(1) — Digital UNIX 4.0d

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

Commands:  kill(1)

nice(1)

renice(8)

runon(1)

w(1)

Functions:  exit(2)

/atexit(2)

/_exit(2)

fork(2)

/vfork(2)

getpriority(2)

/getpriority(2)

exec(2)

wait(2)

/waitpid(2)

/wait3(2)

/wait4(2)

Routines:  nlist(3)

sched_setscheduler(3)

Files:  processor_sets(4)

Standards:  standards(5)

ps(1)  —  Commands

NAME

ps − Displays current process status

SYNOPSIS

Current [XPG4−UNIX] Syntax

ps [−aAdejflm] [−o specifier][=header],...  [−O specifier][=header],...  [−g glist] [−G glist] [−p plist] [−s slist] [−t tlist] [−u ulist] [−U ulist] [−n nlist]

BSD Compatible Syntax

ps [aAeghjlLmsSTuvwx] [o specifier][=header],...  [O specifier][=header],...  [t tty] [process_number]

The ps command displays the current process status. 

STANDARDS

Interfaces documented on this reference page conform to industry standards as follows:

ps:  XPG4, XPG4−UNIX

Refer to the standards(5) reference page for more information about industry standards and associated tags. 

FLAGS

Current Syntax

The following flags can be used with ps:

−aPrints information to standard output about all processes, except the session leaders and processes not associated with a terminal. 

−AWrites information for all processes. 

−dPrints information to standard output about all processes, except the session leaders. 

−ePrints information to standard output about all processes.  Equivalent to -A. 

−fGenerates a full listing. 

−g glistPrints only information about processes that are in the process groups listed in glist.  The glist is a list of process-group identifiers enclosed in " " (double quotes) and separated from one another by a comma or one or more spaces (or tabs), or both.  Because of the way the shell treats spaces and tabs, you need to quote space-separated lists. 

-G glistWrites information for processes whose real group ID numbers or names are given in glist.  The glist is a list of process-group identifiers enclosed in " " (double quotes) and separated from one another by a comma or one or more spaces (or tabs), or both.  Because of the way the shell treats spaces and tabs, you need to quote space-separated lists. 

−j[Digital]  Produces job control information, with fields specified for user, pid, ppid, pgid, sess, jobc, state, tname, time and command. 

−lGenerates a long listing. 

−m[Digital]  Prints all threads in a task, if the task has more than one. 

−o specifier[=header],...
Specifies a list of format specifiers to describe the output format.

Multiple -o flags may be specified.  The final output is a concatenation of all flags specified. 

[Digital]  If the -O flag is used with one or more -o flags, the -O flag must appear first on the command line. 

−O specifier[=header],...
[Digital]  Same as the -o flag, except it displays the fields specified by pid, state, tname, time, and command in addition to the specifiers supplied on the command line. 

[Digital]  The -O flag may be used with one or more -o flags.  The result is a concatenated output.  The -O flag must be specified first. 

-n nlistHistorically, used to specify an alternative system file name list, nlist, in place of the default. 

[Digital]  The name list concept (see the nlist(3) reference page) does not apply to the DIGITAL UNIX ps command; consequently, the −n flag is ignored. 

−p plistDisplays only information about processes with the process numbers specified in plist.  The plist argument is either a list of process ID numbers or a list of process ID numbers enclosed in " " (double quotes) and separated from one another by a comma or one or more spaces (or tabs), or both.  Because of the way the shell treats spaces and tabs, you need to quote space-separated lists. 

−r[Digital]  Enables warning messages. 

−s slist[Digital]  Displays information about processes belonging to the sessions specified in slist.  The slist argument is either a list of session ID numbers or a list of session ID numbers enclosed in " " (double quotes) and separated from one another by a comma or one or more spaces (or tabs), or both.  Because of the way the shell treats spaces and tabs, you need to quote space-separated lists. 

−t tlistDisplays only information about processes associated with the terminals listed in tlist.  The tlist argument is either a list of terminal identifiers or a list of terminal identifiers enclosed in " " (double quotes) and separated from one another by a comma or one or more spaces, or both.  Because of the way the shell treats spaces and tabs, you need to quote space-separated lists. 

Terminal identifiers must be in one of two forms:

     1.The device’s file name

     2.The device’s digit identifier, if the device’s file name begins with tty

−u ulistDisplays only information about processes with the user ID numbers or login names specified in ulist.  The ulist argument is either a list of user IDs or a list of user IDs enclosed in " " (double quotes) and separated from one another by a comma or one or more spaces, or both.  Because of the way the shell treats spaces and tabs, you need to quote space-separated lists. 

In the listing, ps displays the numerical user ID unless the −f flag is used; then it displays the login name. 

-U ulistWrites information for processes whose real user ID numbers or login names are given in ulist.  The ulist argument is either a list of user IDs or a list of user IDs enclosed in " " (double quotes) and separated from one another by a comma or one or more spaces, or both.  Because of the way the shell treats spaces and tabs, you need to quote space-separated lists. 

BSD Compatible Syntax

[Digital]  The following BSD compatible flags can be used with ps (note that these flags are not prefixed with a − (dash) character):

a[Digital]  Asks for information regarding processes associated with terminals (ordinarily only one’s own processes are displayed). 

A[Digital]  Increases the argument space. 

e[Digital]  Asks for the environment to be printed, as well as the arguments to the command. 

g[Digital]  Asks for all processes.  Without this flag, ps only prints interesting processes.  Processes are deemed to be uninteresting if they are process group leaders.  This normally eliminates top-level command interpreters and processes waiting for users to log in on free terminals. 

h[Digital]  Repeats the header after each screenful of information. 

j[Digital]  Produces job control information, with fields specified by user, ppid, pgid, sess, and jobc. 

l[Digital]  Asks for a detailed list, with fields specified by ppid, cp, pri, nice, vsize, rssize and wchan. 

L[Digital]  Lists all available format specifiers. 

m[Digital]  Prints all threads in a task, if the task has more than one. 

o specifier[=header],...
[Digital]  Specifies a list of format specifiers to describe the output format.

O specifier[=header],...
[Digital]  Same as o, except it displays the fields specified by pid, state, tname, cputime, and comm in addition to the specifiers supplied on the command line. 

s[Digital]  Gives signal states of the processes, with fields specified by uid, cursig, sig, sigmask, sigignore, and sigcatch. 

S[Digital]  Prints usage summaries (total usage of a command, as opposed to current usage). 

ttty[Digital]  Lists only processes for the specified terminal. 

T[Digital]  Lists all processes on your terminal. 

u[Digital]  Produces a user oriented output. This includes fields specified by user, pcpu, pmem, vsize, rssize, and start. 

v[Digital]  Produces a version of the output containing virtual memory statistics.  This includes fields specified by cputime, sl, pagein, vsize, rssize, pcpu, and pmem. 

w[Digital]  Uses a wide output format (132 columns (bytes) rather than 80); if this flag is doubled (ww), uses an arbitrarily wide output.  This information determines how much of long commands to print. 

x[Digital]  Asks even about processes with no terminal. 

PARAMETERS

Current Syntax

None

BSD Compatible Syntax

process_number[Digital]  Restricts output to the specified process.  This argument must be entered last on the command line. 

DESCRIPTION

While ps is a fairly accurate snapshot of the system, ps cannot begin and finish a snapshot as fast as some processes change state.  At times there may be minor discrepancies. 

The ps command can be used on multiprocessing systems and for querying the system state of realtime applications for their POSIX priority and scheduling policy. 

Output formats for each process include the process ID (pid), control terminal of the process (tname), CPU time used by the process (cputime) (this includes both user and system time), the state of the process (state), and an indication of the command that is running (command). The abbreviation tty indicates a terminal. 

[Digital]  The state is given by a sequence of letters, for example, RWN.  The first letter indicates the status of the process:

R[Digital]  Runnable process. 

U[Digital]  Uninterruptible sleeping process. 

S[Digital]  Process sleeping for less than about 20 seconds. 

I[Digital]  Idle (sleeping longer than about 20 seconds) process. 

T[Digital]  Stopped process. 

H[Digital]  Halted process. 

[Digital]  Additional characters after these, if any, indicate additional state information:

W[Digital]  Process is swapped out (shows a blank space if the process is loaded (in-core)). 

>[Digital]  Process has specified a soft limit on memory requirements and is exceeding that limit; such a process is (necessarily) not swapped. 

[Digital]  An additional letter may indicate whether a process is running with altered CPU scheduling priority (nice):

N[Digital]  Process priority is reduced. 

<[Digital]  Process priority has been artificially raised. 

+[Digital]  Process is a process group leader with a controlling terminal. 

Format Specifiers

The following list contains all format specifiers that can be used with ps:

Specifier Header Meaning

acflag ACFLG [Digital]  Process accounting flag

args COMMAND Command arguments

comm COMMAND Command name for accounting

command COMMAND [Digital]  Command arguments (and environment with BSD e flag)

cp CP [Digital]  Short-term CPU utilization factor (used in scheduling)

cputime TIME [Digital]  Current CPU time used

cursig CURSIG [Digital]  Current signal

etime ELAPSED Time command has been running

flag F [Digital]  Process flags

group GROUP Group name

inblock INBLK [Digital]  Block input operations

jobc JOBC [Digital]  Current count of processes qualifying PGID for job control

logname LOGNAME [Digital]  User’s login name

longtname TTY [Digital]  Long controlling terminal device name

lstart STARTED [Digital]  Start time and date of process

majflt MAJFLT [Digital]  Page faults

minflt MINFLT [Digital]  Page reclaims

msgrcv MSGRCV [Digital]  Messages received

msgsnd MSGSND [Digital]  Messages sent

nice NI Process scheduling increment (see the setpriority() call). 

nivcsw IVCSW [Digital]  Involuntary context switches

nsignals NSIGS [Digital]  Signals received

nswap NSWAP [Digital]  Swaps

nvcsw VCSW [Digital]  Voluntary context switches

nwchan WCHAN [Digital]  In this case, the initial part of the address is trimmed off and is printed hexadecimally, for example, 0x80004000 prints as 4000. 

oublock OUBLK [Digital]  Block output operations

pagein PAGEIN [Digital]  Number of disk I/Os resulting from references by the process to pages not loaded in core. 

pcpu %CPU Percent CPU usage.  This is a decaying average of 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%. 

pgid PGID Process group ID

pid PID Process ID

pmem %MEM [Digital]  Percent real memory usage

policy POL [Digital]  Current scheduling policy

ppid PPID Parent process ID

pri PRI [Digital]  Process priority

pset PSET [Digital]  Current processor set (^ means bound)

psr PSR [Digital]  Current processor (~ means bound)

psxpri PPR [Digital]  POSIX scheduling priority

rgid RGID [Digital]  Process group (real GID)

rgroup RGROUP Real group name

rssize RSS [Digital]  Real memory (resident set) size of the process (in 1024 byte units)

ruid RUID [Digital]  Process user ID (real UID)

ruser RUSER User ID

scount SCNT [Digital]  Suspend count

sess SESS [Digital]  Session ID

sig PENDING [Digital]  Signals pending to this process

sigcatch CAUGHT [Digital]  Signals being caught

sigignore IGNORED [Digital]  Signals being ignored

sigmask BLOCKED [Digital]  Current signal mask

sl SL [Digital]  Sleep time

start STARTED [Digital]  Start time of process.  If start time was more than 24 hours ago, gives the date. 

state S [Digital]  Symbolic process status

status STATUS [Digital]  Process status

svgid SVGID [Digital]  Saved process group ID

svuid SVUID [Digital]  Saved process user ID

systime SYSTEM [Digital]  Time spent in system

tdev TDEV [Digital]  Major/minor device for controlling terminal

time TIME Current CPU time used

tname TTY [Digital]  Controlling terminal device name

tpgid TPGID [Digital]  Foreground process group associated with terminal

tsession TSESS [Digital]  Session associated with terminal

tty TTY Controlling terminal device name

ucomm COMMAND [Digital]  Command name for accounting

uid UID [Digital]  Process user ID (effective UID)

umask UMASK [Digital]  Process umask

user USER Username

usertime USER [Digital]  Time spent in user space

usrpri UPR [Digital]  Base scheduling priority

u_procp UPROCP [Digital]  Address of process in user area

vsize VSZ [Digital]  Process virtual address size

vsz VSZ Process virtual address size

wchan WCHAN [Digital]  Address of event on which a process is waiting (an address in the system).  A symbol is chosen that classifies the address, if available, from the system; otherwise, it is printed numerically. 

Compound Format Specifiers

[Digital]  Compound format specifiers are made up of groups of individual format specifiers, as follows:

Specifier Meaning

RUSAGE [Digital]  minflt, majflt, nswap, inblock, oublock, msgsnd, msgrcv, nsigs, nvcsw, nivcsw

THREAD [Digital]  user, pcpu, pri, scnt, wchan, usertime, systime

DFMT (default printing format) [Digital]  pid, tname, state, cputime, command

LFMT (BSD l format) [Digital]  uid, pid, ppid, cp, pri, nice, vsz, rss, wchan, state, tname, cputime, command

JFMT (j format) [Digital]  user, pid, ppid, pgid, sess, jobc, state, tname, cputime, command

SFMT (BSD s format) [Digital]  uid, pid, cursig, sig, sigmask, sigignore, sigcatch, stat, tname, command

VFMT (BSD v format) [Digital]  pid, tt, state, time, sl, pagein, vsz, rss, pcpu, pmem, command

UFMT (BSD u format) [Digital]  uname, pid, pcpu, pmem, vsz, rss, tt, state, start, time, command

F5FMT (f format) [Digital]  uname, pid, ppid, pcpu, start, tt, time, command

L5FMT (l format) [Digital]  f, state, uid, pid, ppid, pcpu, pri, nice, rss, wchan, tt, time, ucomm

FL5FMT (lf format) [Digital]  f, state, uid, pid, ppid, pcpu, pri, nice, rss, wchan, start, time, command

SCHED [Digital]  user, pcpu, pri, usrpri, nice, psxpri, psr, policy, pset

Process Flags

The flags associated with process in <sys/proc.h> are as follows:

Symbolic Constant Flag Value (Hex) Meaning
SLOAD 0x00000001 In core
SSYS 0x00000002 [Digital]  Swapper or pager process
SLOMAP 0x00000004 Process allowed to use low virtual memory
SNOTASK 0x00000040 Process completed exit
SWWAIT 0x00000080 Thread is removing zombie
SOMASK 0x00000200 Restore old mask after taking signal
SWEXIT 0x00000400 Working on exiting
SPHYSIO 0x00000800 Doing physical I/O
SVFORK 0x00001000 Process resulted from vfork()
SPAGV 0x00008000 Init data space on demand, from vnode
SSEQL 0x00010000 User warned of sequential vm behavior
SUANOM 0x00020000 User warned of random vm behavior
SCONTIGN 0x00040000 Process is ignoring SIGCONT
S1170 0X00080000 Process is using Single UNIX(R) Specification signal behaviors
SLOGIN 0x00400000 Process marked as a login for Capacity Limitation
SCTTY 0x00800000 Process has a controlling terminal
SXONLY 0x02000000 Process image read-protected
SAIO 0x08000000 Process performed asynchronous I/O
SNOCLDWAIT 0x20000000 No zombies when children exist
SNOCLDSTOP 0x40000000 No SIGCHLD when children stop
SEXEC 0x80000000 Process called exec

<defunct>
A process that has exited but whose parent process has not waited for it.

<error>
[Digital]  A process for which user area information could not be obtained due to a shortage of system memory.

<exiting>
A process that is blocked trying to exit.

ENVIRONMENT VARIABLES

The following environment variables affect the execution of ps:

COLUMNSOverrides the horizontal screen size, used to determine the number of text columns to display. 

LANGProvides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization variables contain an invalid setting, the utility behaves as if none of the variables had been defined. 

LC_ALLIf set to a non-empty string value, overrides the values of all the other internationalization variables. 

LC_CTYPEDetermines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multibyte characters in arguments). 

LC_MESSAGESDetermines the locale for the format and contents of diagnostic messages written to standard error. 

LC_TIMEDetermines the format and contents of the date and time strings displayed. 

NLSPATHDetermines the location of message catalogues for the processing of LC_MESSAGES. 

NOTES

     1.[Digital]  The following BSD compatible flags are not supported.  (You can reconstruct the output of these flags by using the appropriate format specifiers, however.) 

c[Digital]  Displays the command name, as stored internally in the system for purposes of accounting, rather than the command arguments, which are kept in the process’s address space. 

n[Digital]  Displays numeric output.  In a long listing, the wchan field is printed numerically rather than symbolically.  In a user listing, the user field is replaced by a uid field. 

     2.The arguments displayed by args and command format specifiers reflect the arguments passed to the command at its invocation.  Any modification made to the arguments by the running command are not available. 

     3.The arguments displayed by args and command format specifiers are the only output fields that contain embedded blanks, which may be a concern if the output is passed to some type of parser.  Since output fields appear in the order of the format specifiers on the command line, you should put these specifiers at the end of the command if you are using a parser to analyze the output. 

RESTRICTIONS

     1.[Digital]  When you enter a ps command while running an application that forks child processes, you might see some child processes listed as being in the <defunct> state after they have exited.  Processes in this state cannot be killed until the process that forked them is killed. 

[Digital]  The system puts exiting child processes in the <defunct> state if their parent process is still running and has not caught the SIGCHLD signal or executed a wait() system call. 

[Digital]  To avoid having users encounter this problem when they run your application, make sure that your program logic either catches the SIGCHLD signal or executes a wait() system call when spawning a child process. 

     2.[Digital]  It is an error to use two format specifiers, such as comm and ucomm or command and args that are really synonyms for the same output request. 

     3.[Digital]  It is an error to use two or more compound format specifiers that contain the same simple format specifier, or to use a simple format specifier with a compound format specifier that includes the simple specifier. 

EXAMPLES

     1.To list all your processes, enter:

ps

     2.To list all processes, enter:

ps  −A

The BSD equivalent looks like this:

ps ax

     3.To list processes owned by specific users, enter:

ps  −f  −l  −ujim,jane,su

     4.To list processes associated with a specific terminal, enter:

ps  −t console

The BSD equivalent looks like this:

ps tco

     5.To display only the pid, user, and comm information for all processes, enter:

ps −o pid,user,comm −A

     6.To display the parent process ID under the header PARENT, as well as the default headers (fields specified by pid, state, tname, time, command), enter:

ps −O ppid=PARENT

     7.The following ps command shows the use of the SCHED specifier on a two-processor system with two processor sets:

ps -O SCHED
PID USER %CPU PRI UPR NI PPR PSR POL PSET S   TTY        TIME COM
458 root  0.0  43  44  0  20   0  TS    0 I + console 0:01.34 csh
561 root  0.0  44  44  0  19   0  TS    0 I   ttyp0   0:00.42 csh
567 root  0.0  44  44  0  19   1  TS   ^2 I   ttyp0   0:00.03 runon
568 root  0.0  44  44  0  19   1  TS   ^2 I   ttyp0   0:00.03 sh
569 root  0.0  44  44  0  19   1  TS   ^2 S   ttyp0   0:00.31 csh
579 root  0.0  44  44  0  19  ~1  TS   ^2 S + ttyp0   0:00.03 runon
580 root  0.0  44  44  0  19  ~1  TS   ^2 S + ttyp0   0:00.03 sh
581 root  0.0  44  44  0  19  ~1  TS   ^2 R + ttyp0   0:00.06 ls -l

The display shows that all processes are running under the default timershare scheduling policy. Processes 458 and 561 are running unbound to processor 0 in processor set 0. Processes 567, 568, and 569, are running on processor 1 and are bound exclusively (^) to processor set 2. Processes 579, 580, and 581 are running bound to processor 1 (~) and are bound exclusively to processor set 2 (^). 

     8.To display the name of the shell you are currently running, enter:

ps -p $$

FILES

/devSearched to find terminal names. 

/usr/include/sys/proc.h
Process information.

EXIT VALUES

The following exit values are returned:

0Successful completion

>0An error occurred

RELATED INFORMATION

Commands:  kill(1), nice(1), renice(8), runon(1), w(1)

Functions:  exit(2)/atexit(2)/_exit(2), fork(2)/vfork(2), getpriority(2)/getpriority(2), exec(2), wait(2)/waitpid(2)/wait3(2)/wait4(2)

Routines:  nlist(3), sched_setscheduler(3)

Files:  processor_sets(4)

Standards:  standards(5)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026