On segunda-feira, 14 de maio de 2012, às 09.29.11, you wrote: > 2012/5/13 Thiago Macieira <thiago.macie...@intel.com>: > > On domingo, 13 de maio de 2012 18.36.02, Till Oliver Knoll wrote: > >> 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)? > > > > There isn't a platform-independent way. > > And yet there is a Qt API on the "sender side" (parent process) via > QProcess which seems to provide exactly that. Or how is it different > to listen (in the parent process) for incoming messages on "the other > side of the child process' stdout" than to listen on stdin in the > child process itself?
Because on the parent side, we have the low-level OS structure: a pipe, which we createed. On the child side, we don't. All we have is a FILE structure, which doesn't have an API for listening. > So does the implementation of QProcess on Windows start a thread and > does a blocking read on "the other side of the child process' stdout"? > Or does some QTimer based polling? Something like that. The Unix side is very simple: a Unix pipe file descriptor can be put in the select(2) call to wait for input. The Windows side is very, very complex. Take a look at the QProcessPrivate::waitForReadyRead function: it actually does a busy-wait trying to read from the pipe and sleeps. It's horrible. What's more, Qt was not designed for console applications. Starting a sub- process and communicating with it is quite common in GUI applications. Reading from stdin and writing to stdout isn't. You may notice we have very few functions for writing output too. > Sorry, but it's been quite some time ago since my "Design of the Unix > OS" (dup, dup2, fork, select, ...) lectures, I don't have that book > handy right now, and in the meantime I've been spoilt with high-level > APIs such as Qt anyway ;) -- Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel Open Source Technology Center Intel Sweden AB - Registration Number: 556189-6027 Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest