delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2013/02/28/22:39:59

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=BAYES_00,KHOP_SPAMHAUS_DROP,RCVD_VIA_APNIC,SPF_HELO_PASS
X-Spam-Check-By: sourceware.org
Date: 1 Mar 2013 03:39:39 -0000
Message-ID: <20130301033939.72460.qmail@mx.akamoz.jp>
From: smith AT cygwin DOT akamoz DOT jp
To: cygwin AT cygwin DOT com
Subject: stderr for Windows native commands are seemed to be bufferd
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

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?

Best Regards.

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

- Raw text -


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