匿名管道
2016-05-07 08:59
253 查看
//匿名管道 //实现父子进程间的进程通信 //发送简单少量无格式数据 #include <stdio.h> #include <unistd.h> int main() { pid_t child; int fd[2]; int iRead; int iWrite; //create pipe pipe(fd); //create child child = fork(); if(child == 0) { close(fd[1]); while(1) { read(fd[0],&iWrite,sizeof(iWrite)); printf("Shu zi %d \n",iWrite); } close(fd[0]); exit(0); } else { close(fd[0]); while(1) { printf("shu ru\n"); scanf("%d",&iRead); write(fd[1],&iRead,sizeof(iRead)); } close(fd[1]); } return 0; }
相关文章推荐
- CSS3-04 样式 3
- 加强版DVD管理系统
- MapReduce输出格式
- SEO
- COBBLER无人值守安装-----已用真实服务器测试
- [置顶] 决策树算法预测森林植被
- GeoPython 随笔:空间数据查询——测试代码
- Leetcode 28.Implement strStr() 解题报告【C库函数strstr()模拟-字符串中子串首次出现的地址】
- Linux(centOS6.5)下SVN的安装、配置及开机启动
- C++/Php/Python/Shell 程序按行读取文件或者控制台
- NYOJ-93汉诺塔(三)
- 《safe+》离线密码更安全,一键修改最方便
- java多线程技能基础
- Android系统自带样式(@android:style/)
- POJ3233 Matrix Power Series构造矩阵解决问题
- C++3层架构的UML例图
- Linux的原子操作与同步机制
- JAX-RS入门 一 :基础
- jqeury中ajax的表单实现异步提交
- excle中字符串选取#好读书,读好书#--好读书,读好书