Reputation: 18141
I know how a process can respond to signals that were sent to it specifically (e.g. SIGINT
, SIGTERM
, SIGUSR2
, etc.). But can a process be notified of signals that were sent to a different process?
Upvotes: 0
Views: 121
Reputation: 1
Not in standard Unix or POSIX, you cannot be notified for signals sent to another process. See signal(7) and signal-safety(7).
However, waitpid(2) and friends can tell you if a child process has terminated with a signal. And killpg(2) sends a signal to a process group (and kill(2) does also that with a negative target pid). And getrusage(2) can count signals (recieved by some other process). You could also use proc(5) to query information about other processes. And you might use signalfd(2) or ptrace(2) etc....
Signals are a very limited and poor form of inter-process communication. There are better ways.
BTW, sigaction(2) can be used with SA_SIGINFO
and then your handler gets a pointer to siginfo_t
and another to ucontext_t
so you get a lot of information.
Notice that process groups and sessions are related. See also setpgid(2), setsid(2), credentials(7) and also related to terminals and pseudo-ttys (read the tty demystified and about job control).
I guess that your other question is about these. But you don't mention any of them there.
Upvotes: 2