X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=0.4 required=5.0 tests=AWL,BAYES_50,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Date: Tue, 31 Aug 2010 22:40:38 -0400 (EDT) From: Brennan Peter Sellner Reply-To: brennan AT sellner DOT org To: cygwin AT cygwin DOT com Subject: Re: Support for the TIOCINQ ioctl In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="41985805-1146114060-1283308838=:32463" X-SMTP-Spam-Clean: 8% ( MIME_TEXT_ONLY_MP_MIXED 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_1900_1999 0, BODY_SIZE_2000_LESS 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, FROM_NAME_PHRASE 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CP_URI_IN_BODY 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __CTYPE_MULTIPART_MIXED 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __SANE_MSGID 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_MAILTO 0, __URI_NO_WWW 0) X-SMTP-Spam-Score: 8% X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com --41985805-1146114060-1283308838=:32463 Content-Type: TEXT/PLAIN; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8BIT On Sat, 28 Aug 2010, Andy Koppe wrote: > On 27 August 2010 23:31, Brennan Peter Sellner wrote: >> By any chance, has support for the TIOCINQ ioctl on file descriptors (used >> to check how many bytes of data are in the input buffer) been added to >> Cygwin?  It hadn't as of 2004: >> >>  http://sourceware.org/ml/cygwin/2004-07/msg00910.html > > It's still implemented only for serial devices. As I suspected. Thanks for the confirmation. >> ...but I haven't found any newer references to it.  I'm inferring that it's >> not supported, as ioctl(fd, TIOCINQ, &available) (where fd is a valid file >> descriptor, and available is a long) fails, with errno set to 'invalid >> argument'.  I'm running Cygwin 1.7.6 on Vista. >> >> I'm hoping I'm missing something...  Is there an alternative way to check >> the number of bytes on an fd's input buffer in Cygwin? > > What's your use case? And on what sort of fd? > > select() of course can tell you whether there are any bytes available > to be read from an fd, and usually that's all one needs to know. I'm porting a fair chunk of legacy code that spawns processes in the background, provides an emulated tty, and monitors the output, allowing remote clients to interact with the backgrounded processes as if they were running in a local terminal. select can indeed do the trick: there were ioctl calls sprinkled liberally throughout the code, and I was attempting to avoid extensive refactoring. :-) Now that I've refactored things properly using select, things are once again working smoothly. Thanks again, -Brennan --41985805-1146114060-1283308838=:32463 Content-Type: text/plain; charset=us-ascii -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple --41985805-1146114060-1283308838=:32463--