truss Command

You can use the truss command to check if a process is hung. The truss command must be run by the owner of the process or by root.

Use the following command syntax to check if a process is hung:

# truss [ -t syscall ] p pid
-t syscall

Selects system calls to trace

-p pid

Indicates the PID of the process to be traced

syscall is a comma-separated list of system calls to be traced. Starting the list with an ! character excludes the listed system calls from the trace.

Example 6-4 Displaying Process Status

# /usr/bin/truss -p 243
poll(0x00024D50, 2, -1)         (sleeping...)

The example shows that the process is waiting for another connection request, which is a normal response. If the response does not change after a new connection request has been made, the process could be hung.

For information about restarting the NFS service, see How to Restart NFS Service. For information about troubleshooting a hung process, see NFS Troubleshooting Procedures.

You can also use the following options with the truss command to find out about timings of each system call executed by the process.

-d

Represents time in seconds relative to the beginning of the trace

-A

Prints current time of day at the end of a system call

-D

Represents the elapsed time for the LWP that incurred an event, since the last reported event incurred by that LWP

-E

Represents the difference in time elapsed between the beginning and end of a system call

The options are used with the following command syntax:

# truss [ -dADE ] <pid>

Example 6-5 Displaying List of System Calls with the Time Stamps

# /usr/bin/truss -dDE ls
Base time stamp:  1467139321.491964  [ Tue Jun 28 11:42:01 PDT 2016 ]
 0.000000     0.000000     0.000000    execve("/usr/xpg6/bin/ls", 0xFFFF80E3E89E6698, 0xFFFF80E3E89E66A8)  argc = 1
 0.001893     0.001893     0.000042    sysinfo(SI_MACHINE, "i86pc", 257)                = 6

The example shows the list of system calls called by the ls program. The first line of the output gives you the current timestamp at the start of the program. The first column shows the time relative to the base time stamp. The second column represents the elapsed time for the LWP that incurred the event since the last reported event incurred by that LWP. The third column shows the amount of time spent within that system call.

For more information about the available options, see the truss(1) man page.