select() on named pipes

Doug Rudoff doug at wiley.uucp
Fri May 4 10:47:32 AEST 1990


On a DECstations 3100 I am trying to do a select() call to see if
there's data to be read from a named pipe. I set the timeout to be 5
seconds. The problem is that it seems that select() does not recognize
that there is data to be read. Here's what I'm doing:

main()
{
    struct timeval timeout;
    int readfds, n;

    cnt_init();

    timeout.tv_sec = 5;
    timeout.tv_usec = 0;

    /* Wait 5 seconds for data on the pipe and then
       update status lines */
    while (1) {
        readfds = 1 << pipe_fd;
        n = select(1, &readfds, NULL, NULL, &timeout);
        if (n > 0)
             read_pipe();
        else if (n == -1)
            perror("");
        do_maintenance();
    }
}

select() is always returning a zero (after waiting 5 seconds) even if
there is data in the pipe. I know there is data in the pipe since if I
stop the program in the debugger, I can directly call read_pipe() and
get the data that is there.

I have select() working elsewhere with stdin so I think I'm using it
correctly. Am I doing something wrong here or is there a problem with
select() and pipes in Ultrix 3.1?

Doug Rudoff
Mobile Data International
(206) 487-5937
uunet!mdisea!rudoff, rudoff at MDI.COM



More information about the Comp.unix.ultrix mailing list