How to Handle SIGABRT signal?

前端 未结 3 1095
一向
一向 2020-12-03 18:32

Here is the code on which I set my handler for SIGABRT signal then I call abort() but handler does not get trigered, instead program gets aborted,

3条回答
  •  生来不讨喜
    2020-12-03 18:54

    Although you can replace handler for SIGABRT and abort() will pay attention to the handler, the abort is only inhibited if the signal handler does not return. The relevant quote in C99 is in 7.20.4.1 paragraph 2:

    The abort function causes abnormal program termination to occur, unless the signal SIGABRT is being caught and the signal handler does not return. ...

    Your signal handler does return and thus the program is aborted.

提交回复
热议问题