帮忙解释这段代码的执行过程
为什么没有任何输出结果,请分析下:
#include "ourhdr.h"
static int pfd1[2], pfd2[2];
int
main(void)
{
int n, fd[2];
pid_t pid;
char line[MAXLINE];
if (pipe(fd) < 0)
err_sys("pipe error");
if (pid = fork() < 0)
else if (pid > 0)
{
close(fd[0]);
write(fd[1], "hello world\n", 12);
close(fd[1]);
printf("parent process write over\n");
sleep(10);
exit(0);
}
else
{
close(fd[1]);
sleep(3);
n = read(fd[0], line, MAXLINE);
write(STDOUT_FILENO, line, n) ;
}
if (n < 0)
err_sys("read error");
exit(0);
}