On Sunday, November 20, 2011, Arno Trautmann <<a href="mailto:Arno.Trautmann@gmx.de" target="_blank">Arno.Trautmann@gmx.de</a>> wrote:<br>> Hi all,<br>><br>> following Tako's answer to a question on the LuaTeX list¹, it seems that TeXworks' terminal output is block-buffered. That is suboptimal in some special cases, as the one I'm describing in that mail. Is it possible to change this in TeXworks?<br>



><br>> To explain my request: Look at the following plain LuaTeX example:<br>><br>> \let\n\relax<br>> \directlua{<br>>  delay = 1.0<br>>  texio.write_nl("first comment\n")<br>>  os.sleep (delay)<br>



>  texio.write("second comment\n")<br>>  os.sleep (delay)<br>> }<br>> \bye<br>><br>> and have a look at the terminal output in TeXworks, in comparison to compiling a normal terminal. The two comments should be output with a time delay between them, which does not happen with TeXworks (at least not with r.944 on x86_64 Arch Linux)<br>



><br>> Cheers<br>> Arno<br>><br>> ¹<a href="http://tug.org/pipermail/luatex/2011-November/003352.html" target="_blank">http://tug.org/pipermail/luatex/2011-November/003352.html</a><br><br>I did some quick poking by setting the QProcess used to run typesetting tools to use an `Unbuffered` stream. However, the log window still shows the version string when LuaTeX starts up, then waits 2 seconds and shows the rest of the output in one chunk after LuaTeX has finished.<div>


<br></div><div>I think the problem lies with LuaTeX as the behavior of just about every C library is to block buffer output _unless_ the program is communicating with a TTY or the programmer called something like `setbuf(stdout, _IOLBUF)` or uses `fflush` at appropriate locations to flush stdout to the calling process. So, after my test it looks like the log is getting block buffered inside LuaTeX before it even crosses over to TeXworks.</div>


<div><br></div><div>Taco could provide a definite answer as to how stdout buffering is handled on the LuaTeX side.</div><div><br></div><div>-Charlie</div>