[Interest] Piping data between QProcesses

Thiago Macieira thiago.macieira at intel.com
Thu May 29 00:05:24 CEST 2014


Em qua 28 maio 2014, às 23:07:41, qt.dantec at free.fr escreveu:
> Le Sat, 24 May 2014 13:50:45 -0700, Thiago Macieira
> 
> <thiago.macieira at intel.com>  écrivait:
> >Em sáb 24 maio 2014, às 19:15:51, Petko Ditchev escreveu:
> >> [...] I guess I can't call this function a few times for different
> >> processes though ?
> >
> >That question doesn't make sense. Each process has exactly one stdout.
> 
> Thiago,
> 
> I believe the underlying question is : Is there a Qt way to send the
> same information to different process ?

Yes, on Linux you can, but not with QProcess. QProcess will not give you the 
file descriptors for the pipes. If it did, you could simply send the pipe to 
another process via Unix socket file descriptor passing. Just remember to tell 
QProcess to closeWriteChannel(), as two processes can't read from the same 
pipe at the same time. (ENOTOBACCO - Empty pipe)

If you really need this, you can hack QProcess and add the method. I might 
even accept a contribution for Qt 5.4 with the new methods. QFile and 
QAbstractSocket give you a file descriptor, so why not QProcess?

Getting the file descriptors might be useful in other scenarios as well. For 
example, you may need to do some ioctls.
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list