Good Person
Good Person

Reputation: 1443

Is it possible to intercept signals to another process?

Is it possible to trap a signal on the way to another process (which I am not the parent) and instead invoke a local function? In particular when a user sends SIGINFO to a specific process I'd like to trap it and send along a different signal instead. Is this possible at all? would I have to use ktrace / ptrace? Do i need to 'attach a debugger' to it similar to how lldb behaves?

Upvotes: 1

Views: 109

Answers (1)

ArtemB
ArtemB

Reputation: 3622

If you want to do that from userland, then yes, you would have to use ptrace(2) and implement a subset of debugger functionality. I.e. you will need to have appropriate privileges to attach to the process, intercept signals, possibly read and modify registers to change signal number, etc.

Another option would be to make changes to the kernel and implement the functionality you want there. Then you don't have to use ptrace, but the downside is that you'll need a custom kernel.

Upvotes: 1

Related Questions