[Qt-interest] [SOLVED] Does QProcess::readAllStandardOutput have a limit?

Thiago Macieira thiago at kde.org
Fri Dec 3 09:35:42 CET 2010


On Friday, 3 de December de 2010 01:53:59 Eric Clark wrote:
> However, I did go to the printf statement that is used to output from the
> application and changed it to a fputs with a fflush immediately after.
> This solved my problem. I just needed to flush the output stream after I
> wrote to it. Now, everything works great! I really appreciate all of the
> help that everyone gave me.

That's a common problem.

The standard C behaviour is that stdout is buffered and stderr isn't buffered. 
Moreover, they are linked, so writing to stderr flushes stdout. The "surprise 
factor" is the way that stdout is buffered:

 - line buffered (flushes after a \n) if it is connected to a terminal
 - fully buffered (flushes when buffers fill up) otherwise

QProcess uses a pipe to talk to the subprocesses, not a terminal. So it 
triggers the full-buffering functionality.

I didn't suggest this before because you mentioned:

> Myapplication.exe > output.txt

And I didn't know if Windows behaved according to POSIX standards or not. Now 
I know too :-)

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Senior Product Manager - Nokia, Qt Development Frameworks
      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/20101203/8de381e9/attachment.bin 


More information about the Qt-interest-old mailing list