[Qt-interest] QProcess flush issue

Thiago Macieira thiago at kde.org
Mon Oct 31 13:21:00 CET 2011


On Monday, 31 de October de 2011 11:41:17 Etienne Sandré-Chardonnal wrote:
> So the question is : why is the QProcess not able to read more frequently
> from the standard output, where "cmd.exe" can? Is there anything
> configurable somewhere to improve the buffer refresh frequency?

I don't think there's anything wrong with Qt code. It reads as often as the 
underlying child process writes.

You're probably running into a problem in the other application. The C 
library's behaviour is that stdout is line-buffered if it's connected to a 
terminal, but fully buffered if it's not. When QProcess spawns a child process, 
it's using a pipe (not a terminal), so the child process probably uses full 
buffering.

You must cause it to flush its buffer more often. There's no workaround on 
Windows.

If you were on Unix, you could force the behaviour by using a pseudoterminal 
connection. Qt wouldn't help you here, but it would be possible.

> I do not have access to the console app's code.

Contact your vendor and ask them how to make the application flush stdout more 
often.

> I have already read some posts about this but nobody seems to have found
> the solution so far. In most posts, people answers is suggesting that the
> called console app is in cause and not flushing the data enough. But in
> this case, how can windows console print the stdout more frequently? It

See above. The difference is the terminal. Experiment by piping the output to a 
file and confirming how frequently the file grows.

> seems there is a similar issue under linux.
> I have not searched through QProcess source yet. But it seems that QProcess
> is blocking the data in some buffer until a large amount of lines or bytes
> are available.

That's not correct.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20111031/1cbef746/attachment.bin 


More information about the Qt-interest-old mailing list