exit会检查输入输出, 文件等的打开情况, 把缓冲区的内容写回文件, 就是清理i/o。
而_exit则直接释放这些东西。
下面的例子说明了这个问题:
/*exit.c*/#include<stdio.h>
#include<stdlib.h>
int main()
{
printf("Using exit...\n");
printf("This is the content in buffer");
exit(0);
}
打印信息:
Using exit...
This is the content in buffer
说明缓冲区里的内容能正常输出
/*_exit.c*/
#include<stdio.h>
#include<unistd.h>
{
printf("Using exit...\n");
printf("This is the content in buffer");
_exit(0);
}
打印信息:Using _exit...
说明_exit无法输出缓冲区里的记录