QProcess 流执行

/*

_process->start("ps -e");
_process->waitForFinished(-1);
if(!_process->isReadable()) return false;

QString strOutput = _process->readAllStandardError();
if(strOutput.length()==0)
{
strOutput= _process->readAllStandardOutput();
QByteArray arr= strOutput.toStdString().c_str();
_process->start(QString("grep %1").arg(strExe));
_process->write(arr,arr.length());
_process->closeWriteChannel();
_process->waitForFinished();
strOutput= _process->readAllStandardOutput();
if(strOutput.length()>0){
arr= strOutput.toStdString().c_str();
_process->start("awk \"{print $1}\"");
_process->write(arr,arr.length());
_process->closeWriteChannel();
_process->waitForFinished();
strOutput= _process->readAllStandardOutput();
pid= strOutput.remove(QChar('\n'));
}
}else
{
}
_process->close();

QProcess *_iprocess = new QProcess();
qDebug("pid%s",pid.toStdString().c_str());
_iprocess->start(QString("kill %1").arg(strOutput));
_iprocess->waitForFinished();
strOutput = _iprocess->readAllStandardError();

 

qInfo()<<strOutput;

 


_iprocess->close();
qDebug()<<getlocalline<<strOutput;

posted @ 2024-06-07 09:06  WbnProgress  阅读(8)  评论(0编辑  收藏  举报