public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* B20.1++ select bug
@ 2000-01-26  7:35 Michele Liberi
  2000-02-03 14:58 ` Chris Faylor
  0 siblings, 1 reply; 2+ messages in thread
From: Michele Liberi @ 2000-01-26  7:35 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: B20.1++ select bug
  2000-01-26  7:35 B20.1++ select bug Michele Liberi
@ 2000-02-03 14:58 ` Chris Faylor
  0 siblings, 0 replies; 2+ messages in thread
From: Chris Faylor @ 2000-02-03 14:58 UTC (permalink / raw)
  To: Michele Liberi; +Cc: cygwin

On Wed, Jan 26, 2000 at 07:35:24AM -0800, Michele Liberi wrote:
>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.

Sorry.  It is a Windows limitation.  Windows does not always let the other
end of a pipe know when one end disappears.

This may be fixed in a future snapshot but for now it is broken.

cgf

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-02-03 14:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-26  7:35 B20.1++ select bug Michele Liberi
2000-02-03 14:58 ` Chris Faylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).