0
有沒有人看到這個問題,它不工作說壞的文件描述符不知道爲什麼?錯誤的文件描述符
pipe(pipefd[0]);
if ((opid = fork()) == 0) {
dup2(pipefd[0][1],1);/*send to output*/
close(pipefd[0][0]);
close(pipefd[0][1]);
execlp("ls","ls","-al",NULL);
}
if((cpid = fork())==0){
dup2(pipefd[0][1],0);/*read from input*/
close(pipefd[0][0]);
close(pipefd[1][1]);
execlp("grep","grep",".bak",NULL);
}
close(pipefd[0][0]);
close(pipefd[0][1]);
什麼是對pipefd申報? – jemfinch 2010-04-08 02:36:54
int pipefd [3] [2]; – Luke 2010-04-08 02:39:26