[Qt-interest] Problem with sending binary data to stdin of QProcess child. waitForBytesWritten doesn't do the trick
Bart van Deenen
bvandeenen at infologic.nl
Mon Jan 12 08:35:50 CET 2009
On Mon, 2009-01-12 at 08:10 +0100, Bart van Deenen wrote:
> On Sun, 2009-01-11 at 19:59 +0100, Andreas Pakulat wrote:
> > On 11.01.09 19:36:10, Bart van Deenen wrote:
> > > On Sunday 11 January 2009 16:12:57 Andreas Pakulat wrote:
> > > > On 10.01.09 13:16:27, Bart van Deenen wrote:
> > >
> > > > > I'm stuck with getting data from the parent process to the child process
> > > > > though, and I don't see where I'm going wrong.
> > > > > qint64 ct = process.write(s.data(), s.length());
> > > > > the std::string s is a google protocol buffer encoded string, i.e.
> > > > > binary blobs. The current test message has a length of 2 bytes, and I
> > > > > always receive the message "Wrote 2 bytes to child process" so that goes
> > > > > well.
> > > > >
> > > > > On the child receiver side I have a QThread, that should handle the
> > > > > commands on stdin,
> > > > > but It always tells me that there is no data available. ('debug' is a
> > > > > member QFile * for debugging purposes). I've also tried f.open(stdin,...)
> > > > > and std::cin and you name it.
> > >
> > > > Well, you're not closing or flushing stdin of the process, so the data
> > > > might still be in some buffer (Qt or native). So if you don't need stdin
> > > > anymore, just close it on the sender side. Else at least flush it after
> > > > you've written your chunk of data.
I've managed to find previous discussions on this list which mentioned
that QProcess::waitForBytesWritten() should flush the output.
I'll now go have a look if somehow my input routine is buffered or
something.
Thanks
Bart
More information about the Qt-interest-old
mailing list