【发布时间】:2012-01-20 20:45:09
【问题描述】:
这样做是否可能/正确?如果我从“子”进程的 fd1[1] 进行写入,那么是否可以从“父”进程的 fd2[0] 读取?
main(){
pid_t pid;
pid = fork();
if(pid <0){
return -1;
}
if(pid == 0){
int fd1[2];
int fd2[2];
pipe(fd1);
pipe(fd2);
close fd1[1];
close fd2[0];
//writes & reads between the fd1 pipes
//writes & reads between the fd2 pipes
}else{
int fd1[2];
int fd2[2];
pipe(fd1);
pipe(fd2);
close fd1[1];
close fd2[0];
//writes & reads between the fd1 pipes
//writes & reads between the fd2 pipes
}
}
【问题讨论】:
-
那么你的问题是什么?我看起来不像是你自己无法测试的东西。