Also wenn ich diese Fuktion mittels QStringList tmp = getPrcOutP("cat /proc/partitions"); aufrufe passiert anscheinend nichts?!
Das Programm durchläuft anscheinend diese Schleife nicht:
Code: Alles auswählen
while(!txt_stream->atEnd() )
{
std::cout<<"read output: ";
QString tmp_str = txt_stream->readLine();
output.append(tmp_str);
std::cout<<tmp_str.toStdString()<<std::endl;
}Code: Alles auswählen
major minor #blocks name
3 0 78150744 hda
3 1 35840983 hda1
3 2 1 hda2
3 5 20394486 hda5
3 6 17832118 hda6
3 7 3550333 hda7
3 8 530113 hda8
Code: Alles auswählen
QStringList getPrcOutP(QString cmd)
{
QProcess *process = new QProcess();
std::cout<<"try to open: "<<cmd.toStdString()<<std::endl;
process->start(cmd, QIODevice::ReadOnly);
if (!process->waitForStarted() )
std::cout<<"process couldn't get opened"<<std::endl;
QTextStream *txt_stream = new QTextStream(process);
QStringList output;
while(!txt_stream->atEnd() )
{
std::cout<<"read output: ";
QString tmp_str = txt_stream->readLine();
output.append(tmp_str);
std::cout<<tmp_str.toStdString()<<std::endl;
}
return output;
process->close();
}