View Full Version : QProcess with a program that call an other ... find stderror
ilermar
2nd April 2012, 18:53
Hi evivary,
I'm using Qprocess to call a program and this is working but this one calls an other program and that stderror of the second program doesn't appear in the QProcess::readAllStandardError()
Is there a way to do this. To obtain the data in stderror for the other program that is called in the QProcess ?
Hope u understand the problem.
Thanks
ILR
amleto
2nd April 2012, 19:59
you need the first process to forward the standard out/err from the second
ilermar
2nd April 2012, 21:10
you need the first process to forward the standard out/err from the second
The first process call the second so i can´t start one and when this finish stsrat the other.
process->start( "Compiler", args );
but the compiler use preprocesor.exe and this aparently doesn't execute
For example:
When i use the cmd prompt i have this result
>Compiler arch1
> output 1: message
> output 2: message
...
> found errors on arch1
and when i use QProcess the stderror jus give me the last message
>found errors on arch 1
the messages output 1: message are generated by the preprocessor.exe
wysota
2nd April 2012, 23:01
Each process has its own set of standard output channels. They are not inherited within the process group. Thus, as already said, your intermediate process would need to catch and forward output of the final process.
ilermar
2nd April 2012, 23:10
Each process has its own set of standard output channels. They are not inherited within the process group. Thus, as already said, your intermediate process would need to catch and forward output of the final process.
Thnks by the reply and Ok, so the question is how could catch the std output, this is the code that i use:
I have a class MCompiler : public QProcess
MCompiler::MCompiler( )
{
mCompiler = tr( "MCompiler" );
QProcessEnvironment pEnv = QProcessEnvironment::systemEnvironment();
pEnv.insert( "TMPDIR", SSPATH );
setProcessEnvironment( pEnv );
connect( this, SIGNAL( readyReadStandardOutput( ) ), this, SLOT( compileResult( ) ) );
}
here is the code when start my compiler
void MCompiler::compile( QString fileFullPath )
{
QStringList argv;
argv << fileFullPath;
start( mCompiler, argv );
waitForFinished();
}
and i have the signal connected to the slot for read the stdOutput
void SGWMLSCompiler::compileResult()
{
QByteArray bytes = readAllStandardError();
QStringList lines = QString(bytes).split("\n");
foreach (QString line, lines) {
qDebug() << line;
}
}
And here is where i just get the last std output for Compiler.
wysota
3rd April 2012, 00:01
Please understand, there is nothing you can do while calling the "compiler". It is the compiler process that has to catch output of its child process. By the way, you are monitoring standard output but reading standard error. Are you sure you are suppposed to do that?
ilermar
3rd April 2012, 16:20
Thanks wysota. And for your second comment copy-paste error ... but i´m reading the standard output
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.