This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

B20.1++ select bug


I already appended this problem at the mailing list a few days ago. I was 
told to update my system at the latest cygwin1.dll available in the snapshot 
area. It didn't help. That's why I'm sending this help request again. I also 
tryed to upgrade the gcc compiler to 2.95.2 and recompile the program.

The problem is simple: 'select' hangs (do not return) when reading from a 
pipe and the child process exit.

The following C program well illustrates the problem:

#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/select.h>

int main(int argc, char **argv, char **envp)
{
  int                   p1[2], p2[2], maxfd;
  fd_set                fdread;

  if (pipe(p1)) return 1;
  if (pipe(p2)) return 1;
  switch(fork())
  {
    case -1: /* error */
      return 1;
    case 0: /* child */
      close(p1[0]);
      dup2(p1[1],1);
      close(p2[0]);
      dup2(p2[1],2);
      sleep(3);
      return 0;
  }
  close(p1[1]);
  close(p2[1]);

  FD_ZERO(&fdread);
  FD_SET(p1[0],&fdread);
  FD_SET(p2[0],&fdread);
  if (p1[0]>p2[0])      maxfd=p1[0];
    else                maxfd=p2[0];

  printf("select input %d\n", fdread);
  select(maxfd+1,&fdread,NULL,NULL,NULL);
  printf("select output %d\n", fdread);
  return 0;
} /* main */

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]