ps

Report process status (POSIX)

Syntax:

ps [-aAdEfl] [-[gG] grplist] [-o format]... [-n namelist]
   [-p proclist] [-t termlist] [-[uU] usrlist]

Runs on:

QNX Neutrino

Options:

-a
Write information for all processes associated with terminals.
-A
Write information for all processes.
-d
Write information for all processes, except session leaders.
-e
Write information for all processes (the same as -A).
-f
Generate a full listing.
-G grplist
Write information for processes whose real group ID is given in the comma- and space-delimited list, grplist.
-g grplist
Write information for processes whose session leader is given in the comma- and space-delimited list, grplist.
-l
Generate a long listing.
-n namelist
The name of an alternate system namelist file (not supported).
-o format
Write information according to the specifications given in format. If you specify more than one -o option, ps concatenates all the format arguments.
-p proclist
Write information for processes whose ID is given in the comma and space-delimited list, proclist.
-t termlist
Write information for processes whose terminal identifier is given in the comma and space-delimited list, termlist.
-U usrlist
Write information for processes whose real user ID or login name is given in the comma and space-delimited list, usrlist.
-u usrlist
Write information for processes whose user ID or login name is given in the comma and space-delimited list, usrlist.

Description:

The ps utility prints information about processes, subject to having the appropriate privilege to obtain information about those processes. With no options, ps prints information about processes associated with the current terminal. The output includes the process ID, terminal name, cumulative execution time, and command name of each process.

The options that use lists (-G, -g, -o, -p, -t, -U, and -u) can list multiple items separated by commas or white space, as long as all the items are contained within a single command-line argument. If white space is used, you'll probably need to quote the list when invoking ps from the shell.

The initial set of processes selected by -a, -A, or -d is intersected with the processes selected by the -G, -g, -p, -t, -U or -u options, if any of the latter are specified. If a process meets any of the selection criteria, its information is displayed.

If none of -a, -A, or -d is specified, ps behaves as though you specified -u your_uid.

Note: The ps utility doesn't list zombie processes. To check for the presence of zombies in a QNX system, you can use pidin.

Controlling output

The -o option controls the information that ps displays. The format argument is a comma- or space-delimited list of field names that represent information to be displayed about processes and threads.

You can override the header for a field by appending an equals sign and the new header. The rest of the characters in the argument are used as the header text. The ps utility automatically determines the width of all columns.

The ps utility recognizes the following field names:

ruser
The real user name or real user ID of the process.
user
The effective user name or effective user ID of the process.
rgroup
The real group name or real group ID of the process.
group
The effective user name or effective group ID of the process.
pid
The process ID.
ppid
The parent process ID.
pgid
The process group ID.
pcpu
The ratio of CPU time used to CPU time available in a recent period of time.
vsz
The size of the process.
nice
The effective priority of the process.
etime
The elapsed time since the process was started.
time
The cumulative CPU time of the process.
tty
The name of the controlling terminal (currently not supported).
comm
The command being executed.
args
The command with all of its arguments.

The following field names are supported, even though they aren't required by POSIX:

uid
The real user name or real user ID of the process.
env
The environment in a space-delimited list.
f
The process flags.
pri
The real priority of the process.
sid
The process ID of the session leader.
suid
The user ID of the session owner.
sgid
The group ID of the session owner.
umask
The process file creation mask.
sigign
The list of signals ignored by the process.
sigpend
The list of signals pending on the process and threads.
sigqueue
The list of signals queued on the process.
threads
The number of threads for the process.
stime
The process's start time.
cmd
The command being executed.
sz
The size of memory used.
Note: Some of the above fields are thread-specific. In such cases, the value for the first thread in the process is used.

The following field names display information about threads:

tid
The thread ID.
tflags
The thread flags.
dflags
The thread debug flags.
tsigblk
The list of signals blocked on the thread.
cpu
The last CPU the thread ran on.
state
The state of the thread.
wchan
The wait channel.
addr
The wait address.
psched
The scheduling policy.

The comm, args, and env fields are the only ones that can contain blanks.

If you don't specify a format, ps uses:

Examples:

List the process ID, cumulative CPU time, and the command with arguments for all processes, overriding the title of the last column:

ps -A -o "pid,time,args=Command (with args)"

Exit status:

0
Successful completion.
-1
An error occurred.