int main(){
mkfifo("view",0666);
int pid = fork();
if(pid==0){
close(1);
int fd = open("view",O_WRONLY);
dup(fd);
execlp("cat", "cat", "users", NULL);
close(fd);
}
else{
wait(NULL);
int fd = open("view",O_RDONLY);
char resp[100];
read(fd,resp,20);
printf("%s\n",resp);
close(fd);
}
}
我有这段代码,但由于某种原因,当我执行它时,procces死机,没有打印,没有退出(我必须按CTRL + C)。 任何想法为什么?我尝试了同样的事情,但使用内部管道,它工作。Combine fork,fifo和execlp?