How to get the handlers’ name/address for some signals (e.g. SIGINT) in Postgres? We can use signal(SIGINT, my_handler) to set the signal handler, but is there a function that can tell us which function (in this case, my_handler) deals with some signal (in this case, SIGINT)? Or Could we find out using GDB?
How to get the handlers’ name/address for some signals (e.g. SIGINT) in Postgres? We
Share
The function you are looking for is sigaction. It takes three arguments, the first is the signal, the second is a pointer to the new sigaction structure, and the third is a pointer to the old sigaction structure (to be populated by the function). To get the current signal handler, call the sigaction with the second argument set to NULL. For example,
This approach will require you to modify the source.
You may also be able to do this via gdb, which will not require modifying the source. For example, this will work if you attach to the process after it has registered signal handlers.