From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,7a43404c1738618,start X-Google-Attributes: gidfee84,public From: WAIS Administrator Subject: select and poll with nonblocking file descriptors Date: 1997/07/30 Message-ID: <33DFDBBB.6CC5@cmns.think.com>#1/1 X-Deja-AN: 260777258 Reply-To: waisadm@cmns.think.com Organization: Surely you jest! Newsgroups: comp.unix.osf.osf1 In Digital Unix 4.0, select and poll have a "feature" which I'm finding very frustrating. Quoting from "man select": [Digital] Objects ready for the requested operation are those which the operation would not block and not necessarily those which have data avail- able for the operation. True to the man page, select returns immediately if any file descriptor in the fdset is non-blocking, even if there's no data available. Poll works the same way, unsurprisingly. So my question is, if I'm working with file descriptors for sockets or named pipes which are non-blocking, how can I block in select or poll until there really is data available to read? This is the behavior I see in Linux, HPUX, AIX, and Solaris, and it's the behavior expected by the application I'm porting. One approach that I've tried without success is to save, modify, and restore the fd flags around the select call using fcntl. Curiously, turning off O_NONBLOCK before calling select had no apparent effect. A bug?