delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/01/26/10:31:48

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Message-ID: <20000126153524.41585.qmail@hotmail.com>
X-Originating-IP: [195.212.29.117]
From: "Michele Liberi" <mliberi AT hotmail DOT com>
To: cygwin AT sourceware DOT cygnus DOT com
Subject: B20.1++ select bug
Date: Wed, 26 Jan 2000 07:35:24 PST
Mime-Version: 1.0

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 AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019