delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/07/16/11:17:16

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Date: Mon, 16 Jul 2001 17:16:43 +0200
From: Kurt Roeckx <Q AT ping DOT be>
To: cygwin AT cygwin DOT com
Subject: Setting stdin to non-blocking io
Message-ID: <20010716171643.A6752@ping.be>
Mime-Version: 1.0
X-Mailer: Mutt 1.0pre2i

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019