PDA

View Full Version : QProcess StdErr signal question



devx
25th November 2009, 14:40
Im using QProcess (Qt 4.5) to access console (cmd.exe ) in Windows XP.
Is has properly connected stdout/stderr/terminate signals.

When i send something to its write channel it seems to work correctly. CMD responds as it sholud (for ex: dir command,). Im able to read output from stdout channel (result: directory list).
The problem is when i send some garbage (for ex "aksfvakhv"). Console program sends proper stderr output text ("Command not found" or something) and then it terminates! So I need to restart it again. I tried it with another console program and it behaves the same way.

Im using readAllStandardError() to do read stderr channel.
Process sends terminate signal (ExitStatus: NormalExit).



void JGI::readStdError()
{
QByteArray errbuffer=cmdProc->readAllStandardError();
ui->cmdStdError->setText(QString::fromLocal8Bit(errbuffer));
}


Whats wrong?

Signals are connected properly. Checked n times.

caduel
25th November 2009, 16:54
I read your post twice and still am not sure what your problem is. Can you perhaps rephrase it?

devx
25th November 2009, 17:22
The problem is that console process launched by QProcess class terminates itself immediately after sending stderror text message (through stderror channel ofc.).

squidge
25th November 2009, 17:36
What process are you running? Post some code.

It sounds completely normal however. If you post garbage, it complains and terminates. Whats wrong with that?

devx
25th November 2009, 18:15
Normal? For a win cmd.exe ?

It should work like this
----begin
c:\> dir [enter] / stdin <-
dir1 blebelbel / stdout ->
dir2 blebelbel / ..
dir3 blebelbel / ..
....
c:\> garbage [enter] /stdin <-
Unknown command.... /stderr ->
c:\> dir [enter] /stdin <-
dir1 blebelbel /stdout ->
dir2 blebelbe l /..
dir3 blebelbel /..
-----end

But works like this:
----begin
c:\> dir [enter] / stdin <-
dir1 blebelbel / stdout ->
dir2 blebelbel / ..
dir3 blebelbel / ..
....
c:\> garbage [enter] / stdin <-
Unknown command.... / stdout ->
[cmd.exe terminates] / ??? o.O :eek:
-----end

// edit:

Problem solved, it was external program setup fault. Damn.
Topic can be removed, because its a trash...