When abort() is preferred over exit()?

前端 未结 4 1222
傲寒
傲寒 2021-02-02 10:42

I know the differences between the two. One notable thing is that abort() sends SIGABRT signal, so it may be relevant when your software relies on them. But for

4条回答
  •  难免孤独
    2021-02-02 11:16

    Using abort will dump core, if the user has core dumps enabled. So as a rule of thumb, I'd use abort if you're so unsure about what's gone wrong that the only way to get useful information about it is by analysing a core dump.

    If you can safely exit from any given point, and don't need the core dump, then exit is a nicer approach.

提交回复
热议问题