I tried separate channels first, but to make stdout unbuffered, I used merged channel too. no success in both.
what that they expected to have. stderr messages in err file, and stdout menu in out file.[ My fault: when I said no success in getting those lines in redirections, I meant that I couldn't have those lines BEFORE writing to stdin. The problem is to have menu then providing input based on this menu.]
Last edited by resal; 27th August 2007 at 02:21.
Do you know any (not-very-complicated) (especially in Qt4) application with similar functionality? I mean an application which is a GUI that runs some commands AND communicates with those commands while they are still running(i.e. it doesn't wait for commands to finish and then gets the output; rather it gets the messages of commands during execution, displays the messages to user and then writes user options to command stdin). I reviewed konsole code, but got lost in (kde-related) classes....
thanks
Last edited by resal; 27th August 2007 at 11:13. Reason: updated contents
OK, so at least that application isn't playing any tricks by detecting whether the input comes from a file or a terminal.
There is no way to control the buffers through QProcess, but maybe reimplementing QProcess::setupChildProcess() will help. You might try to alter the buffer size with setbuf, but I'm not sure if it's going to work (I think I've tried it to solve a similar problem, but without a success).
Unfortunately, I don't.
kconsole doesn't use pure QProcess, but a K3Process subclass. The most important difference is that KDE allows you to use a pty device to communicate with the child process.
Here are the relevant sources:
http://websvn.kde.org/trunk/KDE/kdeb....h?view=markup
http://websvn.kde.org/trunk/KDE/kdeb...pp?view=markup
http://api.kde.org/4.0-api/kdelibs-a...rocess_8h.html
http://api.kde.org/4.0-api/kdelibs-a...classKPty.html
resal (28th August 2007)
Thank you jacek.
I have reviewed them before. As you said the trick in konsole is using kpty device.
I think this is the case. I 've played with setupChild Process() but I couldn't figured it out how to use it. I found these links though :
http://labs.trolltech.com/blogs/2006...with-qprocess/
http://www.koders.com/default.aspx?s...arch&la=*&li=*
http://www.koders.com/cpp/fidCB4E6B7...upchildprocess
The first one, I think, is the solution. I tried to find some example of its usage, so I search koders, which didn't help me a lot.
Can anyone write an example code about how to use the method that first link suggest?
Thanks in advance.
You have to create a QProcess subclass and use that new class instead.
But as I said, I'm not sure if it's going to help.Qt Code:
{ protected: void setupChildProcess() { ::setbuf( stdout, 0 ); } };To copy to clipboard, switch view to plain text mode
You use it just like QProcess, but I'm not sure if it solves your problem. I think that this class is useful if the process you want to start insists on reading from the terminal. Nevertheless, try it.
Bookmarks