X-Recipient: archive-cygwin@delorie.com
X-SWARE-Spam-Status: No, hits=-1.9 required=5.0	tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_TO_NO_BRKTS_FREEMAIL
X-Spam-Check-By: sourceware.org
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes
To: cygwin@cygwin.com
Subject: Re: Problem with select() on console
References: <4C3E59E3.4050003@hones.org.uk> <20100715054952.GB10561@trixie.casa.cgf.cx>
Date: Thu, 15 Jul 2010 09:54:21 +0200
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
From: "Matthias Andree" <matthias.andree@gmx.de>
Message-ID: <op.vfvj8vwn1e62zd@merlin.emma.line.org>
In-Reply-To: <20100715054952.GB10561@trixie.casa.cgf.cx>
User-Agent: Opera Mail/10.60 (Linux)
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

Am 15.07.2010, 07:49 Uhr, schrieb Christopher Faylor:

> On Thu, Jul 15, 2010 at 01:44:19AM +0100, Cliff Hones wrote:
>> When select() is used to test for input availability on the standard
>> cygwin console in normal (cooked) mode, it indicates input is available
>> as soon as any key is pressed.  However, a call to read(0,...)
>> will (correctly) block until a terminating RETURN is entered.
>>
>> select() should only indicate input is available when a call
>> to read would *not* block - ie when a read call will immediately
>> return at least one character or an error such as EOF.
>>
>> The behaviour of the following test case illustrates this.  When run
>> in a console window typing a single key causes the program to wait
>> for the whole line.  When run under mintty or on Linux the
>> select() calls will continue to return no input until RETURN is
>> entered.
>
> Since, AFAIK, Windows has no way to do this, I don't see how it could be
> done easily.  You could, I guess, pull characters into a buffer until a
> newline was found but that would be pretty error-prone and any use of
> select() would potentially invalidate console i/o for subprocesses.
>
> So, I don't see this changing anytime soon.

Is there a way to detect that the application is run from a Windows  
console rather than mintty?

If so, cygwin1.dll could print a warning to the console, (something along  
the lines that running the application under some X11 terminal or mintty  
is advised) and return EINVAL, or abort the application, in either case if  
POSIXLY_CORRECT is set in the environment, much like some GNU tools will  
switch to a more POSIX compliant behaviour with that variable.

Just a rough thought...

-- 
Matthias Andree

--
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

