LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   View stack of process (https://www.linuxquestions.org/questions/programming-9/view-stack-of-process-865755/)

grob115 03-01-2011 10:14 AM

View stack of process
 
If I issue the following and the process doesn't quit, is there a way to view what it's doing with the SIGTERM signal on the stack? Is this done via the pstack command?
kill -s SIGTERM <PID>

zWaR 03-01-2011 01:37 PM

One way to see what's happening is to use gdb. Before you send the signal, note the proces' ID, fireup gdb and issue the following commands:
Code:

attach PID
continue

Send the singal and then watch what's going on on the stack. The whole procedure is even easier if using ddd.

resetreset 03-03-2011 12:31 PM

I just wanna pick up a little extra knowledge here - do signals go on to the STACK??!!! Can you give a few details about this?

paulsm4 03-04-2011 01:06 AM

Quote:

Q: do signals go on to the STACK
No - of course not!

But a program certainly *has* a stack when it *gets* a signal.

And you can see the stack if you attach to the process with GDB. You can do this in any of three ways:

a) Starting GDB, then "attach" to the already-running PID
b) "run" the process directly from GDB
... or ...
c) Specify the program name and PID as GDB command line arguments ("gdb name-of-executable -pid process-id")

"pstack" is great if the program is conveniently "stopped" for you. But it probably wouldn't work well to try capturing the stack at the moment you hit the signal handler (and catch it before it exited)

grob115 03-04-2011 10:06 PM

What if the program wasn't coded in C? For example, I'm working on a Java program from a vendor and I tried running GDB on it without luck. In this case, if I execute pstack 'PID' would the dumped out information contains the signals? Can you give an example output of pstack and highlight where we can see the signal?


All times are GMT -5. The time now is 04:05 AM.