父子进程间的单向管道通信
2010-01-02 17:17
330 查看
#include<stdio.h> #include<errno.h> #include<unistd.h> int main() { int pid, pipeFD[ 2 ]; char buffer[ 100 ]; if ( pipe( pipeFD ) < 0 ) { printf( "created pipe error/n" ); exit( -1 ); } if( ( pid = fork() ) == 0 ) { close( pipeFD[ 0 ] ); write( pipeFD[ 1 ], "hell", 13 ); write( STDOUT_FILENO, "write done/n", 11 ) ; } else { close( pipeFD[ 1 ] ); read( pipeFD[ 0 ], buffer, 100 ); printf( "%s/n", buffer ); waitpid( pid, NULL, 0 ); } return 0; }
相关文章推荐
- UNIX:在父子进程间用管道技术通信
- [Linux管道和IPC]使用信号量和共享内存进行父子进程通信
- unix学习笔记---------自己写的管道实例----父子进程通信
- UNIX环境高级编程学习之第十五章进程间通信 - 通过半双工匿名管道实现父子进程通信
- 应用管道实现父子进程之间的通信
- linux下父子进程间的通信——管道
- 进程通信(管道 单向通信)
- fork()+pipe() --> 父子进程间通过管道通信
- 简单的实现,在无名管道里父子进程间的通信(大小写的转换)
- 进程通信(管道 单向通信)
- 匿名管道实现父子进程之间的通信....
- 进程通信 (命名管道 单向通信)
- 匿名管道实现父子进程之间的通信....
- 使用pipe()与fork()函数通过管道实现父子进程之间的通信
- linux进程通信之使用匿名管道进行父子进程通信
- 匿名管道实现父子进程之间的通信....
- 应用管道实现父子进程之间的通信
- 进程通信 (命名管道 单向通信)
- 无名管道及用其实现父子进程间的通信
- Linux父子进程通信--管道及FIFO通信