Reputation: 1949
I have a child process which might receive sigterm signal from its parent or from somewhere else. I have to take appropriate action if the signal is from parent. How can i find if the received signal is from parent in c(linux)?
Upvotes: 3
Views: 1389
Reputation: 27542
You set up your signal handler with sigaction
using the SA_SIGINFO
flag. Your handler will accept a parameter of siginfo_t
. Within the siginfo_t struct is the field si_pid
. This is the process id of the sending process. Match that against the child's ppid().
Upvotes: 3