LinuxQuestions.org
Review your favorite Linux distribution.
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 11-26-2008, 08:54 PM   #1
hariprd
LQ Newbie
 
Registered: Nov 2008
Posts: 2

Rep: Reputation: 0
Question How to get the PID of the process giving kill signal to a process?


Hi,

I tried googling but didn't get any answer for this.

I have a process called "abc" and it is running with PID "123".
I have a putty session opened with PID "999".
I am giving kill -TERM 123 from putty session.
My process "abc" before dying it should catch the PID of the terminal which provided TERM signal to it.

Is there any way to find this out?
Your reply with sample pgms are really appreciated...

thanks in advance !

-HP
 
Old 11-26-2008, 11:31 PM   #2
raconteur
Member
 
Registered: Dec 2007
Location: Slightly left of center
Distribution: slackware
Posts: 276
Blog Entries: 2

Rep: Reputation: 44
Assuming your process abc is a C/C++ program you have created or have the source for, take a look at the man page for sigaction, it should get you pointed in the right direction.
Net searches for sigaction should also provide some examples.

Last edited by raconteur; 11-26-2008 at 11:33 PM. Reason: clarification/typo fix
 
Old 11-27-2008, 03:10 AM   #3
hariprd
LQ Newbie
 
Registered: Nov 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Smile

Excellant it works...

Thanks for the suggestion
 
  


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
how a father process know which child process send the signal SIGCHLD icoming Programming 10 07-20-2010 07:26 AM
Shell Script : Kill a running process when another process starts ashmew2 Linux - General 3 08-20-2008 03:47 AM
how to signal a process from another process renjith.rv Linux - Newbie 3 04-23-2008 03:56 AM
Process not killed with -KILL (-9) signal hondo Linux - General 2 07-25-2007 09:23 AM
Looking for a way to find a PID and kill the process it belongs to johngreenwood Programming 6 01-14-2007 05:45 AM

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

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

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