This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

stderr for Windows native commands are seemed to be bufferd


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]