小白笔记----pipe管道(2)(dup的用法)
来源:互联网 发布:淘宝权最新消息 编辑:程序博客网 时间:2024/06/06 11:45
大概理解了dup的意思,mark一下
/*-------2015/10/24----------*/#include<stdio.h>#include<stdlib.h>#include<sys/types.h>#include<unistd.h>#include<string.h>void pipe_read(int p){char m[100] ;read(p,m,100);printf("that: is what we get:%s\n",m);}void pipe_write(int p){char m[100] = "aaron";write(p,m,strlen(m)+1);}main(int agrc,char **argv[],char * environ){int p;pid_t pid;int pipefd[2];p = pipe(pipefd);pid = fork();if(pid < 0){printf("error\n");}if(pid == 0 ){printf("i am a child process\n");close(0);dup(pipefd[0]);close(pipefd[0]);close(pipefd[1]);pipe_read(0);execv("list2",NULL);// The exec() family of functions replaces the current process image witha new process image. exit(0);}if(pid > 0){printf("i am a parent process\n");close(0);dup(pipefd[1]);close(pipefd[1]);close(pipefd[0]);pipe_write(0);wait(NULL);exit(0);}return 0;}
0 0
- 小白笔记----pipe管道(2)(dup的用法)
- 匿名管道 的 管道复制(dup)
- 小白笔记-------------pipe管道(1)(后续还有哦)
- java NIO之管道Pipe()的用法
- Linux 管道(pipe)
- 管道(pipe)
- 管道(PIPE)
- 管道命令(pipe)
- 管道(pipe)
- linux下的pipe()管道函数
- pipe(fork, execvp, dup, dup2)
- Angular2 中管道@Pipe的简单用法
- Angular 2的管道Pipe
- Angular 2的管道Pipe
- linux管道通信(pipe)
- 管道的应用(pipe)《深入分析Linux内核源码》
- SQL Server使用的协议:Named Pipe(命名管道)
- 进程间的通信方式——pipe(管道)
- 如何用Maven创建web项目(具体步骤)
- Alcatraz不显示Load Bundle解决办法
- Java-HttpSession
- opencv学习笔记(十五)——图像融合
- 软件开发过程
- 小白笔记----pipe管道(2)(dup的用法)
- opencv 使用tic toc 来记录时间
- hdu2102 bfs
- 提交商店xcode 7 90049 ERROR ITMS-90535 Unexpected 解决办法
- Spark入门_2_LoadSaveData
- Android 命名规范 (提高代码可以读性)
- Linux内核与实现
- 树上倍增求LCA(最近公共祖先)
- 进程的简单介绍