select & pipe does not work!

Peter.Eggimann@mgb.ch Peter.Eggimann@mgb.ch
Fri May 16 06:22:00 GMT 1997


Hi, 
I encountered a problem while porting some software. The select call
(waiting for a pipe) returns immediate even thougt there is no data
available from the pipe.
Then I tried a small test program (see below) and encountered the same
problem.

pipetest.c
------------------------------------------------------------------------
------------------------
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/select.h>
#include <sys/types.h>


main ()
{
    int result;
    int pipeFd [2];

    struct fd_set rset;

    if (pipe( pipeFd) < 0) {
        printf ("Error %d creating pipe\n", errno);
        exit (-1);
    }


    FD_ZERO (&rset);
    FD_SET (pipeFd[0], &rset);

    result = select (pipeFd[0]+1, &rset, (fd_set*)0,
                     (fd_set*)0, (struct timeval*)0);

    switch (result) {
        case 0:
            printf ("Select: received 0 ?!?\n");
            break;

        case -1:
            printf ("Select: Error occured\n");
            break;

        default:
            printf ("normal event\n");
            break;
    }
return (0);
}


------------------------------------------------------------------------
------------------------

compiled whith:
gcc -g -o pipetest pipetest.c

I've installes b18 on NT4.0. The same code on a UN*X box works fine.

Has anyone any ideas?
-
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