Exit functions in C

前端 未结 4 869
礼貌的吻别
礼貌的吻别 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-18 00:00

    From man:

    exit:
    All functions registered with atexit(3) and on_exit(3) are called, in the reverse order of their registration ... All open stdio(3) streams are flushed and closed. Files created by tmpfile(3) are removed.

    _exit:
    The function _exit() is like exit(3), but does not call any functions registered with atexit(3) or on_exit(3). Whether it flushes standard I/O buffers and removes temporary files created with tmpfile(3) is implementation-dependent. On the other hand, _exit() does close open file descriptors ...

提交回复
热议问题