delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=2.0 required=5.0 tests=AWL,BAYES_00,BOTNET,KHOP_THREADED,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_NO,RCVD_IN_HOSTKARMA_YE |
X-Spam-Check-By: | sourceware.org |
Message-id: | <51302CCD.6020201@cygwin.com> |
Date: | Thu, 28 Feb 2013 23:21:33 -0500 |
From: | "Larry Hall (Cygwin)" <reply-to-list-only-lh AT cygwin DOT com> |
Reply-to: | cygwin AT cygwin DOT com |
User-Agent: | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130215 Thunderbird/17.0.3 |
MIME-version: | 1.0 |
To: | cygwin AT cygwin DOT com |
Subject: | Re: stderr for Windows native commands are seemed to be bufferd |
References: | <20130301033939 DOT 72460 DOT qmail AT mx DOT akamoz DOT jp> |
In-reply-to: | <20130301033939.72460.qmail@mx.akamoz.jp> |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
On 2/28/2013 10:39 PM, smith AT cygwin DOT akamoz DOT jp wrote: > The stderr for Microsoft Windows native commands is undesirably > buffered when they are executed on Cygwin shell, Like this: > > $ uname -a > CYGWIN_NT-6.1 localhost 1.7.17(0.262/5/3) 2012-10-19 14:39 i686 Cygwin > $ which nslookup > /cygdrive/c/Windows/system32/nslookup > $ nslookup > ... >> set q=hogehoge >> set q=fugafuga >> exit > unknown query type: hogehoge > unknown query type: fugafuga > $ > > The error messages "unknown query type" should comes just after > "set q=" input respectively. > > Create a simple program as follows: > > #include <stdio.h> > int main(void) { > fprintf(stderr, "hogehoge\n"); > /* fflush(stderr); */ > getchar(); > fprintf(stderr, "fugafuga\n"); > return 0; > } > > Build the program by MSVC: > > c:\>cl /? > Microsoft(R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86 > Copyright (C) Microsoft Corporation. All rights reserved. > > On Microsoft's cmd, everything goes fine. On bash in Cygwin, > first waiting for input, then 2 lines are printed. > If I insert fflush just before getchar, it works well both environments. > > Who is buffering the stderr output? Is there any workaround? Windows is buffering because it sees the Cygwin ptys as a pipe (and it buffers on pipes for performance reasons). The alternative is to start bash from cmd.exe instead of mintty or other Cygwin terminal. See the email archives for more discussion of this issue if you're interested. -- Larry _____________________________________________________________________ A: Yes. > Q: Are you sure? >> A: Because it reverses the logical flow of conversation. >>> Q: Why is top posting annoying in email? -- 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
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |