exit函数和_exit函数之间的区别
来源:互联网 发布:linux 安装万兆网卡 编辑:程序博客网 时间:2024/05/16 09:42
#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<unistd.h>
int main()
{
pid_t result;
result = fork();
if(result<0)
perror("fork");
if(result == 0)
{
printf("This is _exit test\n");
printf("This is the content in the buffer000");
_exit(0);
}
else
{
printf("This is exit test\n");
printf("This is the content in the buffer");
exit(0);
}
return 0;
}
这是别人的实例代码,我借用一下哈
这里说明一下,printf是标准io函数,当遇到\n换行符的时候,才会将缓冲区里面的内容进行输出
运行结果是
This is exit test
This is the content in the buffer
This is _exit test
首先输出的是父进程里面的内容,首先将
This is exit test放进缓冲区,然后遇到换行符,输出This is exit test
然后将This is the content in the buffer放进缓冲区,
然后exit(0)由于,exit函数会冲洗缓冲区,那么
This is the content in the buffer也会被输出
接下来就是子进程了,首先
This is _exit test放进缓冲区
然后遇到换行符,输出内容
接下来把
This is the content in the buffer000放进缓冲区,由于没有换行符
并且_exit(0函数不会冲洗缓冲区,所以This is the content in the buffer000
这条语句不会输出
那么exit函数和_exit函数之间的区别就是exit会将缓冲区里面的内容写回文件
#include<stdlib.h>
#include<sys/types.h>
#include<unistd.h>
int main()
{
pid_t result;
result = fork();
if(result<0)
perror("fork");
if(result == 0)
{
printf("This is _exit test\n");
printf("This is the content in the buffer000");
_exit(0);
}
else
{
printf("This is exit test\n");
printf("This is the content in the buffer");
exit(0);
}
return 0;
}
这是别人的实例代码,我借用一下哈
这里说明一下,printf是标准io函数,当遇到\n换行符的时候,才会将缓冲区里面的内容进行输出
运行结果是
This is exit test
This is the content in the buffer
This is _exit test
首先输出的是父进程里面的内容,首先将
This is exit test放进缓冲区,然后遇到换行符,输出This is exit test
然后将This is the content in the buffer放进缓冲区,
然后exit(0)由于,exit函数会冲洗缓冲区,那么
This is the content in the buffer也会被输出
接下来就是子进程了,首先
This is _exit test放进缓冲区
然后遇到换行符,输出内容
接下来把
This is the content in the buffer000放进缓冲区,由于没有换行符
并且_exit(0函数不会冲洗缓冲区,所以This is the content in the buffer000
这条语句不会输出
那么exit函数和_exit函数之间的区别就是exit会将缓冲区里面的内容写回文件
阅读全文
0 0
- exit函数和_exit函数之间的区别
- exit函数和_exit函数的区别
- exit和_exit函数的区别
- exit和_exit两个函数的区别
- exit() _exit()函数的区别
- exit() 与 _exit() 函数调用之间的区别
- exit函数 和 _exit函数区别
- linux中_exit函数和exit函数的区别
- exit()和_exit()函数
- exit()和_exit()函数
- exit()和_exit()函数
- exit()和_exit()函数
- exit()和_exit()函数
- exit()和_exit()函数
- 函数exit()和_exit()
- exit()和_exit()函数
- exit()和_exit()函数
- exit()和_exit()函数
- 极光推送
- DM368开发 -- 再论 UBL
- Tensorflow安装
- PMP
- 量子计算入门-第二部分
- exit函数和_exit函数之间的区别
- MongoDB一个基于分布式文件存储的数据库(介于关系数据库和非关系数据库之间的数据库)
- 数论——洛谷 P1445 没占到1444的愤怒
- sql语句中select……as的用法
- Struts2框架action传入页面list对象集合,修改对象集合数据后提交给action
- For input string:"name"
- Spring4 Mybatis3 的开发配置
- java常用数据结构---线性表---链式存储
- 小光棍数