Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-01-2011, 10:14 AM   #1
Registered: Oct 2005
Posts: 540

Rep: Reputation: 32
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>
Old 03-01-2011, 01:37 PM   #2
Registered: Dec 2003
Distribution: Slackware, Alpine Linux, Ubuntu, Debian
Posts: 219

Rep: Reputation: 35
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:
attach PID
Send the singal and then watch what's going on on the stack. The whole procedure is even easier if using ddd.
Old 03-03-2011, 12:31 PM   #3
Senior Member
Registered: Mar 2008
Location: Cyberspace
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,340

Rep: Reputation: 62
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?
Old 03-04-2011, 01:06 AM   #4
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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)
Old 03-04-2011, 10:06 PM   #5
Registered: Oct 2005
Posts: 540

Original Poster
Rep: Reputation: 32
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?


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
single 8K process stack vs 4K process stack and a seperate 4K interrupt stack charvak Linux - Kernel 1 03-17-2010 06:58 PM
Getting the stack size of a process aravinda78 Programming 4 12-12-2008 08:32 AM
stack trace of a process node047 Linux - Newbie 2 04-01-2005 09:11 PM
Accessible stack memory for a process on IA-64 muzzafukka Linux - General 0 05-24-2004 08:57 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:53 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration