LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 03-01-2011, 10:14 AM   #1
grob115
Member
 
Registered: Oct 2005
Posts: 542

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
zWaR
Member
 
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:
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.
 
Old 03-03-2011, 12:31 PM   #3
resetreset
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
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

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

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?
 
  


Reply



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

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