Giter Club home page Giter Club logo

Comments (1)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 28, 2024
I'm afraid this is yet another instance of issue 56.

Mintty is based on Cygwin/MSYS pseudo terminal devices (ptys), which are 
implemented using Windows pipes. This means that in a MinGW-compiled program 
running in mintty, stdout will be a pipe.

The key to the problem is that stdout's default buffering mode depends on the 
type of device: unbuffered for a console, buffered for a pipe. This means that 
in a console the output will appear immediately, whereas in mintty it will only 
appear once the buffer is either full or flushed, as happens at the end of 
main().

Hence there are two ways to work around this: call fflush(stdout) whenever 
output needs to appear, or switch stdout to unbuffered mode at the start of the 
program, like so:

  setvbuf(stdout, 0, _IONBF, 0);

Switching it to line buffering, e.g. with setvbuf(stdout, 0, _IOLBF, BUFSIZ), 
ought to work too, but apparently with MinGW that has the same effect as 
enabling full buffering, because it causes your test to fail in the console too.

The issue appears in other programs that redirect stdio via pipes too, e.g. 
Eclipse: https://bugs.eclipse.org/bugs/show_bug.cgi?id=199219.

Programs built with the Cygwin or MSYS compilers are not affected by this.

Original comment by andy.koppe on 12 Sep 2010 at 4:50

  • Changed state: Duplicate

from mintty.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.