System Administration Guide, Volume 2

Controlling Processes (/proc Tools)

You can control some aspects of processes by using some of the process tools contained in /usr/proc/bin. The table below lists these process tools. Refer to proc(1) for detailed information about process tools.

Table 35-3 Process Tools

Tools That Control Processes 

What the Tools Do 

  

/usr/proc/bin/pstop pid

Stops the process 

/usr/proc/bin/prun pid

Restarts the process 

/usr/proc/bin/ptime pid

Times the process using microstate accounting 

/usr/proc/bin/pwait [-v] pid

Waits for specified processes to terminate 

  

Tools That Display Process Details 

What the Tools Display 

  

/usr/proc/bin/pcred pid

Credentials 

/usr/proc/bin/pfiles pid

fstat and fcntl information for open files

/usr/proc/bin/pflags pid

/proc tracing flags, pending and held signals, and other status information for each lwp

/usr/proc/bin/pldd pid

Dynamic libraries linked into each process 

/usr/proc/bin/pmap pid

Address space map 

/usr/proc/bin/psig pid

Signal actions 

/usr/proc/bin/pstack pid

Hex+symbolic stack trace for each lwp

/usr/proc/bin/ptree pid

Process trees containing specified pids 

/usr/proc/bin/pwdx pid

Current working directory 

In these commands, pid is a process identification number. You can obtain this number by using the ps -ef command.

Chapter 35, Managing Processes (Tasks) describes how to use the process tool commands to perform selected system administration tasks, such as displaying details about processes, and starting and stopping them. A more detailed description of the process tools can be found in proc(1).

If a process becomes trapped in an endless loop, or if it takes too long to execute, you may want to stop (kill) the process. See Chapter 35, Managing Processes (Tasks) for more information about stopping processes using the pkill command.

The previous flat /proc file system has been restructured into a directory hierarchy that contains additional sub-directories for state information and control functions.

It also provides a watchpoint facility that is used to remap read/write permissions on the individual pages of a process's address space. This facility has no restrictions and is MT-safe.

The new /proc file structure provides complete binary compatibility with the old /proc interface except that the new watchpoint facility cannot be used with the old interface.

Debugging tools have been modified to use /proc's new watchpoint facility, which means the entire watchpoint process is faster.

The following restrictions have been removed when setting watchpoints using the dbx debugging tool:

See proc(4), core(4), and adb(1) for more information.


Note -

To avoid typing long command names, add the process tool directory to your PATH variable. This allows you to run process tools by entering only the last part of each file name (for example, prun instead of /usr/proc/bin/prun).


How to Control Processes

  1. (Optional) Use output from the ps command to obtain the identification number of the process you want to display more information about.


    # pgrep process
    

    process

    Name of the process you want to display more information about. 

    The process identification number is in the first column of the output.

  2. Use the appropriate /usr/proc/bin command to control the process.


    # /usr/proc/bin/pcommand PID
    

    pcommand

    Process tool command you want to run. Table 35-3 lists these commands.

    PID

    Identification number of a process. 

  3. Verify the process status using the ps command.


    # pgrep PID
    

Example--Controlling Processes

The following example shows how to use process tools to stop and restart Print Tool.


# PATH=$PATH:/usr/proc/bin
# export PATH 1
# ps -e | grep print* 2
264 console 0:03 printtool
# pstop 264 3
# prun 264 4
# ps | grep 264
264 console 0:03 printtool
#
  1. Adds the /usr/proc/bin directory to the PATH variable.

  2. Obtains the process identification number for Print Tool.

  3. Stops the Print Tool process.

  4. Restarts the Print Tool process.