Exit functions in C

前端 未结 4 883
礼貌的吻别
礼貌的吻别 2021-01-17 23:40

What is the difference between exit(), _exit() and _Exit() in C?

How do I decide which to use?

On bash, <

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-17 23:47

    exit() terminating after cleanup.

    _exit() terminating immediately after call.

    If you have some stack corrupted while exit() function was called program may close with Segmentation Fault, if you are use _exit(), program exit in quick mode.

    From http://msdn.microsoft.com/en-us/library/6wdz5232.aspx you have

    exit() - Performs complete C library termination procedures, terminates the process, and exits with the supplied status code.

    _exit() - Performs quick C library termination procedures, terminates the process, and exits with the supplied status code.

    _cexit() - Performs complete C library termination procedures and returns to the caller, but does not terminate the process.

    _c_exit() - Performs quick C library termination procedures and returns to the caller, but does not terminate the process.

提交回复
热议问题