When abort() is preferred over exit()?

前端 未结 4 1217
傲寒
傲寒 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条回答
  •  -上瘾入骨i
    2021-02-02 11:16

    Use abort() if your program is in a possibly corrupt state and you consider it too dangerous to try to do anything further. exit() will cause any atexit functions, and in C++ destructors of static objects, to be called. This is usually what you want for a clean exit, but it could be catastrophic if, for example, they overwrite a file with corrupt data.

提交回复
热议问题