Setting stdin to non-blocking io

Kurt Roeckx Q@ping.be
Mon Jul 16 08:16:00 GMT 2001


I'm having a problem setting stdin to non-blocking io.  The read
always seems to block.

I've tried using both ioctl() and fcntl().

This program for example:

#include <unistd.h>
#include <sys/ioctl.h>
#include <termios.h>

int     main(void)
{
        int     val;
        char    buf[10];

        val = 1;
        ioctl(0, FIONBIO, &val);

        read(0, buf, sizeof(buf));
        return 0;
}

It should just return to the prompt directly without reading
anything, but it waits for the user to hit enter.

Doing this:

        val = fcntl(sock, F_GETFL, 0);
        fcntl(sock, F_SETFL, val|O_NONBLOCK);

Does just the same.

I'm doing this on win98 with cygwin 1.3.2.

I assume I have to do something else to get it working properly,
since other programs seem to be able to do it (like bash, vim,
...)

Kurt


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list