Search code examples
printingterminalvala

Vala Print Output Visible in Terminal only after Window is Closed


I am learning vala (after a couple years of Java) and I have this very simple code, just to make a few tests :

button_2.clicked.connect (() => {
    string test = "hello";
    stdout.printf (test);
});

It is a Gtk.Window class, and when I run it and click the button, say five times, nothing happens.

Then, when I close the window, all five print outputs appear together in the terminal.

 hellohellohellohellohello

In a Java application, after each click of a button, the output individually shows in the terminal.

I wonder why a Vala app doesn't print while the window is open, and if there is a way around it.


Solution

  • Output is being buffered. Insert a newline, or call stdout.flush().