Section 3.4. Tools for Listing and Controlling Processes


3.4. Tools for Listing and Controlling Processes

Solaris provides a set of tools for listing and controlling processes. The general syntax is as follows:

$ ptool pid $ ptool pid/lwpid 


The following is a summary for each. Refer to the man pages for additional details.

3.4.1. Process Tree: ptree

The process parent-child relationship can be displayed with the ptree command. By default, all processes within the same process group ID are displayed. See Section 2.12 in Solaris™ Internals for information about how processes are grouped in Solaris.

$ ptree 22961 301   /usr/lib/ssh/sshd   21571 /usr/lib/ssh/sshd     21578 /usr/lib/ssh/sshd       21580 -ksh         22961 /opt/filebench/bin/filebench           22962 shadow -a shadow -i 1 -s ffffffff10000000 -m /var/tmp/fbench9Ca           22963 shadow -a shadow -i 2 -s ffffffff10000000 -m /var/tmp/fbench9Ca           22964 shadow -a shadow -i 3 -s ffffffff10000000 -m /var/tmp/fbench9Ca           22965 shadow -a shadow -i 4 -s ffffffff10000000 -m /var/tmp/fbench9Ca ... 


3.4.2. Grepping for Processes: pgrep

The pgrep command provides a convenient way to produce a process ID list matching certain criteria.

$ pgrep filebench 22968 22961 22966 22979 ... 


The search term will do partial matching, which can be disabled with the -x option (exact match). The -l option lists matched process names.

3.4.3. Killing Processes: pkill

The pkill command provides a convenient way to send signals to a list or processes matching certain criteria.

$ pkill -HUP in.named 


If the signal is not specified, the default is to send a SIGTERM.

Typing pkill d by accident as root may have a disastrous effect; it will match every process containing a "d" (which is usually quite a lot) and send them all a SIGTERM. Due to the way pkill doesn't use getopt() for the signal, aliasing isn't perfect; and writing a shell function is nontrivial.

3.4.4. Temporarily Stop a Process: pstop

A process can be temporarily suspended with the pstop command.

$ pstop 22961 


3.4.5. Making a Process Runnable: prun

A process can be made runnable with the prun command.

$ prun 22961 


3.4.6. Wait for Process Completion: pwait

The pwait command blocks and waits for termination of a process.

$ pwait 22961 (sleep...) 


3.4.7. Reap a Zombie Process: preap

A zombie process can be reaped with the preap command, which was added in Solaris 9.

$ preap 22961 (sleep...) 





Solaris Performance and Tools(c) Dtrace and Mdb Techniques for Solaris 10 and Opensolaris
Solaris Performance and Tools: DTrace and MDB Techniques for Solaris 10 and OpenSolaris
ISBN: 0131568191
EAN: 2147483647
Year: 2007
Pages: 180

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net