B20.1++ select bug
Michele Liberi
mliberi@hotmail.com
Wed Jan 26 07:35:00 GMT 2000
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
More information about the Cygwin
mailing list