Possible Bug in Pipes with Win95

marcus@bighorn.dr.lucent.com marcus@bighorn.dr.lucent.com
Tue Oct 28 08:31:00 GMT 1997


First off, there is a problem in the logic of your test program.

   ...

  /*  Create the pipe. */
  status = pipe (mypipe);
  if (status) 
    { 
      fprintf (stderr, "Pipe failed.\n"); 
      return EXIT_FAILURE; 
    } 
  
  /* Create the child process. */
  pid = fork ();

  if (pid == (pid_t) 0) 
    { 
      /* This is the child process. */
      read_from_pipe (mypipe[0]); 
      fprintf(stdout, "Child:  Exiting. . . ");
      exit(EXIT_SUCCESS); 
    } 

    ...

The pipe is created, then fork() is called.  At this point, both processes
have a copy of the read end and write ends of the pipe.  Now, the child
starts reading from the read end of the pipe and waits for EOF.  Note that
EOF occurs when all writers have closed the pipe and both the parent and
child process have a write end open, so the child should never see EOF
until it closes its write end of the pipe, which it never does.

Also, just a minor style point here, I would never call a file descriptor
"file", since a stream is of type FILE *.  Traditionally, it is "fd" or
something else ending in "d".  Not that it really makes any difference for
functionality, but just for readability by other Unix types..

marcus hall
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".



More information about the Cygwin mailing list