0
可以/正確地做到這一點嗎?如果我從「子」進程的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
}
}
那麼你的問題是什麼?我看起來不像你無法測試自己的東西。 – Tudor