LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   How to get the PID of the process giving kill signal to a process? (http://www.linuxquestions.org/questions/programming-9/how-to-get-the-pid-of-the-process-giving-kill-signal-to-a-process-686517/)

hariprd 11-26-2008 08:54 PM

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

raconteur 11-26-2008 11:31 PM

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.

hariprd 11-27-2008 03:10 AM

Excellant it works...

Thanks for the suggestion :)


All times are GMT -5. The time now is 04:37 PM.