1

Is it possible that signal handling can be done for a particular process only.

For Ex:-

2 Independent different process A & B are running in background & signal handling for SIGTERM has been done only in the code for process A. So, if I will send the SIGTERM to process B to terminate it then the signal handler function in process A will execute & I want that the signal handler will execute only when the SIGTERM is sent to process A.

Note:- I am using Linux OS.

So, is there any way for achieving the above.

Debugger
  • 17
  • 4
  • I may have misunderstood but I think you'd have to implement handling in B also and use `kill(...)` to 'forward' the signal - in order to forward SIGTERM to A, B must know A's PID. So much for independence tho – ben10 Oct 16 '21 at 18:40
  • Are you saying that you’re *seeing* A handle a signal “sent to B” and you *want* A to handle only its own signals? – Davis Herring Oct 16 '21 at 20:20
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 17 '21 at 10:20
  • I am saying that signal handling for signal SIGTERM is done only in code of Process A not in B & when I want to terminate process B then I am sending SIGTERM to process B but, in that case I believe the Signal Handler for Process A will execute instead I want signal handler in A should run only when I send SIGTERM to process A only. – Debugger Oct 17 '21 at 20:36

0 Answers0