[Interest] QProcess: child read from stdin - no data received?
Till Oliver Knoll
till.oliver.knoll at gmail.com
Sun May 13 19:51:22 CEST 2012
Am 13.05.2012 um 18:36 schrieb Till Oliver Knoll <till.oliver.knoll at gmail.com>:
> Hello,
>
> this seems to be an ever recurring topic: How does one get notified in a *child* process (started via QProcess) once there is data to be read on stdin (in a platform-independent matter - but for now mostly OS X)?
I came to realise that stdin/out are really *text*-based and trying to re-open them in binary mode is also not guaranteed to work everywhere:
http://bytes.com/topic/c/answers/213649-how-write-binary-data-stdout
As I really want to send raw JPEG binary data from parent to child this IPC solution is a dead-end anyway.
Next: QLocalServer/Socket. I assume in the parent process I start a QLocalServer, start a child process via QProcess and pass along the "server connect information" as arguments, and then in the child process connect to the parent process' server. That should hopefully give me a bi-directional (local socket or pipe) connection with "bytesAvailable" signals on both ends.
It remains to be seen whether the parent process with *no* network entitlement ("OS X sandboxing") can actually create a local server...
If that would fail, what remains is QSharedMemory. But to my understanding that would require to "poll some memory addresses" wheter the other process wants to "send a message". Not to mention that I need to send data of variable size (JPEG), so I would probably end up in a "memory-based block read/write protocol": "I have written 1024 KBytes of JPEG data into the shared memory block, more to follow (poll for ACK) - Ok, got it (poll for more data) - Here is the next block of 1024 KBytes - Ok, bring it on... - Here are the last 42 KBytes - Got it..." doh!
I hope the local socket approach works...
Cheers,
Oliver
More information about the Interest
mailing list