How to extract the program call stack of a Unix/Linux process which is stuck?

Document ID : KB000045453
Last Modified Date : 14/02/2018
Show Technical Document Details

Question: 

How can I extract the program call stack of a process which appears to stall or does not shutdown on Unix/Linux?

 Answer: 

    Solaris:

Open a command prompt and execute the following command:

 pstack [process ID] > /tmp/aehang.txt

  Linux:

Open a command prompt and execute the following command:

pstack [process ID] > /tmp/aehang.txt

 

3)      IBM AIX:

Open a command prompt and execute the following command:

procstack [process ID] > /tmp/aehang.txt

 

4)      HP-UX (requires installation of HP Wildebeest Debugger - WDB):

Open a command prompt and execute the following commands:

 a. script /tmp/aehang.txt

b. gdb -p [process ID]

 c. At the gdb prompt, type the following gdb commands:

            set pagination off [enter]

info threads [enter]

thread apply all bt [enter]

quit [enter]

d. Type control+D complete the recording of your console session into file /tmp/aehang.txt.

 

Additional Information:

Collecting process dump/pstack/procstack/gdb as shown above just once shows the state of threads at that point of time alone and may not be very useful.

So, we request to repeat the below process for at the least 4-5 times with a gap of a minute between each collection to see if the process really stalled.