Unix doesn't work !

Miyazaki Randy randy at retix.retix.COM
Fri Mar 24 12:14:24 AEST 1989


Why does the child read not terminate with a End of File indication ?
Bizzarely enough, the program hangs both under BSD 4.3 and
S5R3 (Interactive VP/IX 1.0.6). This seems to contradict any
documentation on pipes I have seen.

int pipefd[2];
char buf;

main()
{
  int len;
  
  if (pipe(pipefd) < 0)
    {
      perror("pipe");
      exit(1);
    }
  if (fork())
    {
      /* Parent process here */
      printf("reading...\n");
      len = read(pipefd[0], &buf, 1);
      printf("child read return %d\n", len);
      if (len < 0)
	perror("read");
      exit(0);
    }
  sleep(2);
  printf("child process exiting, parent read should return EOF\n");
  exit(0);
}



More information about the Comp.unix.questions mailing list