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]

select & pipe does not work!


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".


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