[Qt-interest] newbie:facing issues with readallstdoutput andQProcess

Andreas Pakulat apaku at gmx.de
Tue May 5 09:48:37 CEST 2009


On 04.05.09 21:16:33, Thiago Macieira wrote:
> Em Segunda-feira 04 Maio 2009, às 20:43:01, Will Rutherdale (rutherw) 
> escreveu:
> > I've been testing QProcess on a Linux machine.  I have my Qt program run
> > a script that does output to a mix of STDERR and STDOUT.  The Qt program
> > connects to all the advertised signals in QProcess, and mostly works.
> >
> >  
> >
> > I read the QProcess documentation and accordingly called
> > setProcessChannelMode( QProcess::MergedChannels ) before calling
> > start().  
> >
> >  
> >
> > In my readyReadStandardOutput handler, I call readAllStandardOutput().
> > This is supposed to get all the output of the script from both STDOUT
> > and STDERR.  Unfortunately it only gets the output from STDERR.  The
> > output from STDOUT appears not to be available anywhere.  If I modify
> > the script and make all of its output go to STDERR, then the Qt program
> > sees everything.
> >
> >  
> >
> > Is this a known bug in QProcess?
> 
> No. Please understand that stdout is buffered in C (and so is cout in 
> iostream). So unless you flush the data, you won't see anything. Stderr, 
> however, is not buffered, so anything you write will be seen.

I've recently had to learn that this is not the case on all platforms that
Qt runs on. At least I had a case on win32 where writing to stderr was
buffered as well as stdout making the reading process (in java) not see the
stderr output until the child process finished.

Andreas

-- 
You will be run over by a bus.



More information about the Qt-interest-old mailing list