I registered a handler of
fprintf(stderr, "SIGSEGV , TID: %d,PID: %d\n", TEST_ID, getpid());
Can't I use
exit()to normal finish the process in the handler?
exit() should not be called from a signal handler as it isn't guaranteed to be async-signal-safe. Use
printf() should not be called from a signal handler for the same reason that applies to
For a full list of functions being async-signal-safe or not please have look down on this pages:
Moreover, the moment a segmentation violation occured the program is unstable, or even broken, the stack may me smashed, so there is no guarantee that anything may be called at all from that moment on.