1

I have read this discussion which discuss about how to check the signal actions of each process: How can I check what signals a process is listening to?

However, I want to use C/C++, Python or other ways to get the userspace of the signal handler name of each process. Just like the psig in Solaris: What is the meaning of every column when executing psig command?

Would it be possible to do that in Linux?

2 Answers2

1

The signal function returns a pointer to the existing handler, if any. You can set a signal to a known value, get the existing handler's address and restore it.

Thomas Dickey
  • 76,765
  • I just want to know how to get the handler's name, such as termsig_sighandler in this discussion: https://unix.stackexchange.com/questions/163573/what-is-the-meaning-of-every-column-when-executing-psig-command – user2365346 Jul 30 '18 at 00:34
  • Restoring the value may fail with SIG_ERR. That's not a pretty situation to handle. – Aykhan Hagverdili Sep 12 '22 at 09:23
0

Using sigaction instead of signal makes it possible to request the current signal handler without setting another handler. You just need to pass NULL as the second argument:

Please see this answer for a code example.

proski
  • 176