Signal Processing with gdb

I am debugging a C ++ application for Ubuntu 10.04 that sometimes receives a signal SIGKILL. I want to catch a signal and stop it from killing, just to see if I can get useful information about the state of the application at that moment.

Reading gdb documentation I found a command handle, so I tried to apply it to a SIGKILL signal:

(gdb) handle SIGKILL stop nopass
Signal        Stop  Print   Pass to program Description
SIGKILL       Yes   Yes     No              Killed

So, as I understand it correctly:

stop
    GDB should stop your program when this signal happens. This implies the print keyword as well. 
print
    GDB should print a message when this signal happens. 
nopass
    GDB should not allow your program to see this signal. 

as soon as a signal is issued SIGKILL, it gdbmust somehow catch it, print a message, stop execution and prevent the application from killing itself, right?

The problem is that this does not happen and the application terminates.

Do you know how I can catch a signal?

Helpful information:

  • , , .
  • gdb: 4.4.3
  • g++: 7.1
+4
1

unix- (7) man-:

  The  signals SIGKILL and SIGSTOP cannot be caught, blocked, or ignored.

, , . . SIGKILL , . SIGKILL : -)

+5

Source: https://habr.com/ru/post/1541748/


All Articles