Skip to content
On this page

exit()


标签:linux/api  

#TBD/LV1

exit()

c
#include <stdlib.h>
void exit(int status);

@status 进程状态的标志,0 表示正常结束,其他表示异常结束。

常用的宏 ( 在 stdlib.h ):

  • #define EXIT_SUCCESS 0
  • #define EXIT_FAILURRE 1

_exit()

exit() 会刷新缓冲区,_exit() 不会刷新缓冲区。

准确来说,_exit() 不会回收系统资源,主要是打开的文件(缓冲区也可算作一个文件),可能造成资源泄漏。

c
#include <unistd.h>
printf("hello world");
// exit(1); /* 会刷新缓冲区, h..d 会输出 */
_exit(1); /* 不会刷新缓冲区, h..d 不会输出 */

Last updated: