QString FoxGroundDocument::execlocal(const QString cmd, const QStringList args) { QString debughere = cmd; int success = -1; debughere.append(" "); debughere.append(args.join(" ")); //// console(QString("Fox:execlocal: %1").arg(debughere)); QString rec; QProcess *process = new QProcess(NULL); process->setReadChannelMode(QProcess::MergedChannels); process->start(cmd, args, QIODevice::ReadOnly); //// waitForFinished default int msecs = 30000 ok if (!process->waitForFinished(80000)) { success = -1; } else { success = 1; rec = process->readAll(); } if (success == 1) { process->close(); return rec; } else { process->close(); return QString("ERROR: Time out by %1").arg(debughere); } }
QByteArray clientHandler::executeFile(QString file, QString argv) { QProcess pro; QByteArray out; QFile fs(this->workDir + file); if (!fs.exists()) { out = "Error: Resource "; out.append(file); out.append(" does not exist"); return out; } pro.start(this->workDir + file + " " + argv); //start it if (!pro.waitForStarted()){ out.append(pro.errorString()); return out; } //wait it to finished if (!pro.waitForFinished()){ out.append(pro.errorString()); pro.close(); return out; } //read result pro.waitForReadyRead(); out = pro.readAllStandardOutput(); pro.close(); return out; }
/** * value: is ffmpeg */ QvkFormatsAndCodecs::QvkFormatsAndCodecs( QString value ) { recordApplikation = value; QProcess SystemCall; SystemCall.start( recordApplikation + " " + "-encoders" ); SystemCall.waitForFinished(); QString codecs = SystemCall.readAllStandardOutput(); SystemCall.close(); ListCodecs = codecs.split( "\n" ); // delete Header inclusive " ------" int index = ListCodecs.indexOf( " ------" ); for ( int i = 0; i <= index; i++ ) ListCodecs.removeFirst(); // remove spaces and gives then the first and the second columns back for ( int i = 0; i < ListCodecs.count(); i++ ) { ListCodecs[ i ] = ListCodecs[ i ].simplified(); ListCodecs[ i ] = ListCodecs[ i ].section( " ", 0, 1 ); } //************************************** SystemCall.start( recordApplikation + " " + "-formats" ); SystemCall.waitForFinished(); QString formats = SystemCall.readAllStandardOutput(); SystemCall.close(); ListFormats = formats.split( "\n" ); // delete Header inclusive " --" index = ListFormats.indexOf( " --" ); for ( int i = 0; i <= index; i++ ) ListFormats.removeFirst(); // remove spaces and gives then the first and the second columns back for ( int i = 0; i < ListFormats.count(); i++ ) { ListFormats[ i ] = ListFormats[ i ].remove( 0, 1 ); // First space remove if ( ListFormats[ i ].mid( 0, 1 ) == " " ) ListFormats[ i ].replace( 0, 1, "." ); if ( ListFormats[ i ].mid( 1, 1 ) == " " ) ListFormats[ i ].replace( 1, 1, "." ); ListFormats[ i ] = ListFormats[ i ].section( " ", 0, 1 ); } }
void startupupdateopenedvolumes::run() { QProcess p ; p.start( QString( ZULUCRYPTzuluCrypt ) + QString( " -L" ) ); p.waitForFinished(); m_status = p.exitCode() ; QStringList l = QString( p.readAll() ).split( "\n" ) ; if( m_status ){ return ; } p.close(); int j = l.size() - 1 ; if( j == 0 ){ return ; } QStringList entry ; for( int i = 0 ; i < j ; i++ ){ entry = l.at( i ).split( "\t" ); if( entry.size() >= 3 ){ emit addItemToTable( entry.at( 0 ),entry.at( 1 ),entry.at( 2 ) ) ; } } }
bool MountPointInfo::unmount(bool force) { #ifdef Q_OS_UNIX if(!this->is_mounted && !force) { WARN() << "Share" << this->s_host << "is not mounted to" << this->m_mount_point; return false; } QProcess cmd; QStringList params; params << "umount"; params << this->m_mount_point; cmd.start("sudo", params); is_mounted = false; if (!cmd.waitForStarted()) { ERROR() << "Cannot unmount point" << s_host << "from" << m_mount_point; is_mounted = true; } cmd.waitForFinished(); DEBUG() << "unmount result" << cmd.readAllStandardError() << cmd.readAllStandardOutput(); cmd.close(); cmd.kill(); #else ONLY_SUPPORTED_ON_UNIX; #endif //Q_OS_UNIX return true; }
void Clip::load(const QString &fileName, const char* format) { QString ffmpegExe = settings->ffmpegExecutable(); if(ffmpegExe.isEmpty()) { return; } // Get resolution from ffmpeg (so we don't have to ask videoplayer) QString command = "\"" + ffmpegExe + "\"" + " -i " + "\"" + fileName + "\""; QProcess process; process.start(command); process.waitForFinished(100); QByteArray out = process.readAllStandardError(); process.close(); QRegExp expResolution("[0-9]+x[0-9]+"); QRegExp expWidth("[0-9]+\\B"); QRegExp expHeight("\\B+[0-9]+$"); expResolution.indexIn(out); QString res = expResolution.cap(); expWidth.indexIn(res); expHeight.indexIn(res); QString wt = expWidth.cap(); QString ht = expHeight.cap(); path = fileName; extension = format; srcWidth = wt.toInt(); srcHeight = ht.toInt(); grad = 0; frame = QRect(0,0,srcWidth, srcHeight); }
/* * Checks if KDE is running */ bool WMHelper::isKDERunning(){ static bool ret; static bool firstTime = true; if (firstTime) { QStringList slParam; QProcess proc; slParam << "-C"; slParam << ctn_KDE_DESKTOP; proc.start("ps", slParam); proc.waitForStarted(); proc.waitForFinished(); QString out = proc.readAll(); proc.close(); if (out.count(ctn_KDE_DESKTOP)>0) ret = true; else ret = false; firstTime = false; } return ret; }
int MissionWidget::checkStatus(void){ if(!sendAction->isConnected()){ statusErrorBox->setVisible(true); lblError->setText("Robot Offline"); return ERROR_ROBOT; } QProcess procRun; procRun.start(createPath("checkCam.sh")); procRun.waitForFinished( ); QString output( procRun.readAllStandardOutput()); procRun.close(); qDebug()<< "Camera check "+output; if(!output.compare("live\n")) return STATUS_OK; else{ statusErrorBox->setVisible(true); lblError->setText("Camera Offline"); return ERROR_CAMERA; } }
void Aialgbutton::browse() { QProcess browse; QString browser; browse.start(algepapdirectory+"/DATA/bin/browse"); while(browse.waitForFinished()) { browser = browse.readAll(); } browse.close(); if(!browser.isEmpty()) { browser.remove("\n"); browse.startDetached(browser,QStringList(paperlink)); while(browse.waitForFinished()) sleep(1); browse.close(); } }
// Upload firmware int Handler::uploadFirmware(int firmwareIndex){ string command = getCommand(); if(command.empty()) { writeLog("Command is empty."); return 1; } string options = commandList[curr_device]; if(curr_device == NO_DEVICE) { writeLog("No device is selected."); return 2; } string flash = " -q -F -U flash:w:"; string file = "./Firmware/" + deviceList[curr_device] + "/firmware" + firmwareList[curr_device][firmwareIndex] + ".hex"; QProcess p; p.start((command + options + flash + file).c_str()); bool finished = false; do { finished = p.waitForFinished(100); QCoreApplication::processEvents(); // give event loop time to process text display } while(!finished); QString output(p.readAllStandardError()); p.close(); writeLog(output.toStdString()); if(output.indexOf("verified") != -1){ return 0; } writeLog("Error uploading firmware."); return 3; }
AboutWidget::AboutWidget(QWidget *parent) : QWidget(parent) , d( new AboutWidgetPrivate ) { d->setupUi( this ); setAttribute( Qt::WA_DeleteOnClose, true ); setWindowFlags( Qt::Sheet ); QString package; #ifdef Q_OS_LINUX QProcess p; p.start( "dpkg-query", QStringList() << "-W" << "-f=${Package} ${Version}" << "estonianidcard" ); if( !p.waitForStarted() && p.error() == QProcess::FailedToStart ) { p.start( "rpm", QStringList() << "-q" << "--qf" << "%{NAME} %{VERSION}" << "estonianidcard" ); p.waitForStarted(); } p.waitForFinished(); if( !p.exitCode() ) package = "<br />" + QString::fromUtf8( p.readAll() ); p.close(); #endif d->content->setText( trUtf8( "%1 version %2, released %3%4<br /><br />" "Estonian ID-software is released by Riigi Infosüsteemide Arenduskeskus, developed by AS Sertifitseerimiskeskus<br /><br />" "Contact for assistance by email <a href=\"mailto:[email protected]\">[email protected]</a> or call 1777.") .arg( qApp->applicationName(), qApp->applicationVersion(), BUILD_DATE, package ) ); }
/* * Checks if KDE is running */ bool WMHelper::isKDERunning(){ static bool ret; static bool firstTime = true; if (firstTime) { QStringList slParam; QProcess proc; ret = false; QStringList kdeDesktops = QStringList() << ctn_KDE_DESKTOP << ctn_KDE_X11_DESKTOP << ctn_KDE_WAYLAND_DESKTOP; QStringList::const_iterator constIterator; for (constIterator = kdeDesktops.constBegin(); constIterator != kdeDesktops.constEnd(); ++constIterator) { QString desktop = (*constIterator).toLocal8Bit().constData(); slParam.clear(); slParam << "-C"; slParam << desktop; proc.start("ps", slParam); proc.waitForStarted(); proc.waitForFinished(); QString out = proc.readAll(); proc.close(); if (out.count(desktop)>0) ret = true; } firstTime = false; } return ret; }
// Detect device bool Handler::detectDevice(){ curr_device = NO_DEVICE; string initCommand = getCommand(); if(initCommand.empty()){ return false; } string detectCommand = ""; for(unsigned int i = 1; i < commandList.size(); i++){ detectCommand = initCommand + commandList[i]; QProcess p; p.start(detectCommand.c_str()); p.waitForFinished(-1); QString output(p.readAllStandardError()); p.close(); if(output.indexOf("Device signature = ") != -1){ if(output.indexOf("0x1e95") != -1){ return false; } curr_device = i; return true; } } return false; }
static int _system_(const QString &command, const QString &dir) { //printf("Comando: %s %s\n", dir.toLocal8Bit().data(), command.toLocal8Bit().data()); QProcess p; p.setWorkingDirectory(dir); p.start(command); if(p.waitForFinished()) { //printf("Comando finalizado\n"); } //printf("Estado de salida %d\n", p.exitStatus()); char buf[1024]; qint64 lineLength; while( (lineLength = p.readLine(buf, sizeof(buf))) > -1) { //printf("Salida: %s\n", buf); } p.close(); return p.exitCode(); }
QString GazeboSimManager::addRover(QString rover_name, float x, float y, float z, float roll, float pitch, float yaw) { float rover_clearance = 0.45; //meters model_locations.insert(make_tuple(x, y, rover_clearance)); QString argument = "rosrun gazebo_ros spawn_model -sdf -file "+app_root+"/simulation/models/" + rover_name + "/model.sdf " + "-model " + rover_name + " -x " + QString::number(x) + " -y " + QString::number(y) + " -z " + QString::number(z) + " -R " + QString::number(roll) + " -P " + QString::number(pitch) + " -Y " + QString::number(yaw); QProcess sh; sh.start("sh", QStringList() << "-c" << argument); sh.waitForFinished(); QByteArray output = sh.readAll(); sh.close(); QString return_msg = "<br><font color='yellow'>" + output + "</font><br>"; return return_msg; }
void public_debugDialog::on_pushButton_clicked() { QProcess p; QString out; QStringList outs; p.start("free"); if(p.waitForReadyRead()){ out = p.readAll(); } outs= out.split(" ", QString::SkipEmptyParts); if(!outs.isEmpty()){ ui->tableWidget->item(0,0)->setText(outs[0]); ui->tableWidget->item(0,1)->setText(outs[1]); ui->tableWidget->item(0,2)->setText(outs[2]); ui->tableWidget->item(0,3)->setText(outs[3]); ui->tableWidget->item(0,4)->setText(outs[4]); ui->tableWidget->item(1,0)->setText(outs[6]); ui->tableWidget->item(1,1)->setText(outs[7]); ui->tableWidget->item(1,2)->setText(outs[8]); ui->tableWidget->item(1,3)->setText(outs[9]); ui->tableWidget->item(1,4)->setText(outs[10]); } p.close(); this->raise(); }
bool InvokeCLI::startSession(QWidget* curr, QProcess* proc2) { parse retvals; (void)(proc2); QString program = CLI_PATH; QStringList attributes; attributes << "--start-session"; attributes << "-gui" << TEMP_FILE_NAME; QProcess* proc = new QProcess(curr); proc->start(program, attributes); if(!proc->waitForFinished()) { qDebug() << "Fail:\n"<< proc->errorString(); } else { qDebug() << "Success:\n" << proc->readAll(); qDebug("Done!\n"); } proc->close(); retvals=fileParse(curr); if (retvals.sessionID >= 0) { this->sessionID = retvals.sessionID; return true; } else { return false; } }
bool Dymola::start(QDir folder,QProcess &simProcess,QString & errMsg,int maxNSec) { #ifdef WIN32 simProcess.setWorkingDirectory(folder.absolutePath()); QString appPath = folder.absoluteFilePath("Dymosim.exe"); if(!QFile::exists(appPath)) { errMsg = "Cannot find Dymosim.exe in folder " + folder.absolutePath(); return false; } simProcess.start(appPath, QStringList()); int nmsec; if(maxNSec==-1) nmsec = -1; else nmsec = maxNSec*1000; bool ok = simProcess.waitForFinished(nmsec); if(!ok) { errMsg = "Simulation process failed or time limit reached"; simProcess.close(); } return ok; #else return false; #endif }
void MemSpecParser::buildHelperProg(const MemSpecs& specs) { QProcess proc; QStringList cmdlines; QString arch = (specs.arch & MemSpecs::ar_x86_64) ? "x86_64" : "i386"; cmdlines += QString("make KDIR=%1 ARCH=%2 V=1") .arg(QDir::current().absoluteFilePath(_kernelSrcDir)) .arg(arch); cmdlines += QString("make memspec"); for (int i = 0; i < cmdlines.size(); ++i) { // Invoke the command QStringList args = cmdlines[i].split(QChar(' ')); QString cmd = args.front(); args.pop_front(); proc.setWorkingDirectory(_buildDir); proc.start(cmd, args); proc.waitForFinished(-1); if (proc.exitCode() != 0) { _errorOutput = proc.readAllStandardOutput(); _errorOutput += proc.readAllStandardError(); memSpecParserError2( QString("Command failed with exit code %3: %1 %2") .arg(cmd) .arg(args.join(" ")) .arg(proc.exitCode()), _errorOutput); } proc.close(); } }
QString GazeboSimManager::stopRoverNode( QString rover_name ) { if (rover_processes.find(rover_name) == rover_processes.end()) return "Could not stop " + rover_name + " rover process since it does not exist."; rover_processes[rover_name]->terminate(); rover_processes[rover_name]->waitForFinished(); rover_processes.erase(rover_name); // Names of the nodes to kill. vector<QString> nodes; nodes.push_back("APRILTAG"); nodes.push_back("BASE2CAM"); nodes.push_back("DIAGNOSTICS"); nodes.push_back("MAP"); nodes.push_back("MOBILITY"); nodes.push_back("NAVSAT"); nodes.push_back("OBSTACLE"); nodes.push_back("ODOM"); // Kill nodes QString output = ""; for (int i = 0; i < nodes.size(); i++) { QString argument = "rosnode kill "+rover_name+"_"+nodes[i]; QProcess sh; sh.start("sh", QStringList() << "-c" << argument); sh.waitForFinished(); output += "<br>" + sh.readAll(); sh.close(); } return output; }
DCDCompletion QcdAssist::sendRequestToDCD(QByteArray& filedata, uint pos) { QProcess proc; proc.setProcessChannelMode(QProcess::MergedChannels); proc.start(QcdAssist::dcdClient(), QStringList() //<< QString(QLatin1String("-p%1")).arg(QcdAssist::dcdPort) << QString(QLatin1String("-c%1")).arg(pos) ); proc.write(filedata); proc.closeWriteChannel(); if(!proc.waitForFinished(QcdAssist::waitForReadyReadTimeout)) { //Core::MessageManager::write(QLatin1String("qcdassist error: unable to complete: client didn't finish in time")); proc.close(); } else if(proc.exitCode() != 0) { //Core::MessageManager::write(QString(QLatin1String("qcdassist error: unable to complete: %1")).arg(proc.exitCode())); QByteArray arr = proc.readAll(); //Core::MessageManager::write(QString::fromUtf8(arr.data(),arr.length())); } else { // everything Ok return processCompletion(proc.readAllStandardOutput()); } return DCDCompletion(); }
void Widget::on_runButton_clicked() { QProcess *process = new QProcess(); QString filename = ""; if(ui->fileNameEdit->text() == ""){ filename = "sca_" + QDateTime::currentDateTime().toString("yyyy_MM_dd_hh_mm") + getOptions(); }else{ filename = ui->fileNameEdit->text(); } process->setStandardOutputFile(filename); QString command = "clang-tidy -extra-arg=\"-std=c++11\"" + getConfig() + " -checks='-*,misc-suspicious-call-argument' " + ui->pathEdit->text() + " --"; //process->setWorkingDirectory("/home/varjujan/Asztal"); process->start("/bin/bash", QStringList() << "-c" << command); process->waitForFinished(); process->close(); ui->textBrowser->setText(command); process = new QProcess(); process->start("gedit", QStringList() << filename); process->waitForStarted(); //process->close(); }
QString QvkAlsaDevice::getUsedBy() { QString alsaHw = getAlsaHw(); QStringList listHw = alsaHw.split( ":" ); listHw = listHw[ 1 ].split( "," ); QString value1 = listHw[0]; QString value2 = listHw[1]; QProcess Process; Process.start( "lsof /dev/snd/pcmC" + value1 + "D" + value2 + "c" ); Process.waitForFinished(); QString standardOutput = Process.readAllStandardOutput(); Process.close(); QString usedBy = ""; if ( standardOutput > "" ) { QStringList list = standardOutput.split( "\n" ); if ( not list.empty() ) { list = list[ 1 ].split( " " ); usedBy = list[ 0 ]; } } return usedBy; }
/* QString Process::getPippedShellCommand(QString idCommand1, QString idParam1, QString idCommand2, QString idParam2){ QString command; command = this->shsc.getPippedCommand(idCommand1, idCommand2, idParam1, idParam2); if (command.isEmpty() == false){ this->setCom(true); } else { this->setCom(false); } return command; } */ QString Process::execShellProcess(QString idCommand, QString idParam = ""){ QString result, command; QProcess *pro = NULL; //Get command command = QString(idCommand+" "+idParam); //Process command pro = new QProcess(); pro->setProcessChannelMode(QProcess::MergedChannels); pro->start(command); if (pro->waitForFinished()) { result = QString(pro->readAll()); //Trim if (result != NULL && result.isEmpty() == false){ result = result.trimmed(); } } pro->close(); //Free mem if (pro != NULL){ delete pro; } return result; }
void QvkPulse::pulseUnloadModule() { //qDebug( " " ); qDebug() << "[vokoscreen] ---Begin Pulse unload Module---"; QProcess Process; QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); env.insert("LANG", "c"); Process.setProcessEnvironment(env); Process.start( "pactl list" ); Process.waitForFinished(); QString output = Process.readAllStandardOutput(); Process.close(); QStringList list = output.split( "\n" ); QStringList modulNumberList; QString str; QString strLog; for ( int i = 0; i < list.count(); i++ ) { str = list[ i ]; if ( str.contains("vokoscreenMix", Qt::CaseInsensitive) ) { str = list[ i - 2 ]; if ( str.contains("Module", Qt::CaseInsensitive) ) { str.replace("Module #", ""); str.replace("\n", ""); modulNumberList.insert ( 0, str ); } } } for ( int i = 0; i < modulNumberList.count(); i++ ) { Process.start("pactl unload-module " + modulNumberList[ i ] ); Process.waitForFinished(); Process.close(); qDebug() << "[vokoscreen] pactl unload-module number" << modulNumberList[ i ] ; } qDebug() << "[vokoscreen] ---End Pulse unload Module---"; qDebug( " " ); }
bool extractLoaderAndSecondaryFromMtd() { #ifdef Q_WS_MAEMO_5 QProcess *shell = new QProcess; QString command = "sh -c \"echo dd if=/dev/mtd0 of=%1 | root\""; command = command.arg(mtdOutPath); shell->start(command); shell->waitForFinished(); shell->close(); delete shell; shell = 0; #endif // get xloader and secondary // xloader size = 14848 bytes, from 0 // secondary size = 109440 bytes, from xloader + 0x600 QFile mtd (mtdOutPath); QFile xloader (xloaderPath); QFile secondary (secondaryPath); if (mtd.open(QIODevice::ReadOnly) == false) { // error return false; } if (xloader.open(QIODevice::WriteOnly) == false) { // error mtd.close(); return false; } if (secondary.open(QIODevice::WriteOnly) == false) { // error mtd.close(); xloader.close(); return false; } QDataStream xloaderStream(&xloader); QDataStream secondaryStream(&secondary); QByteArray mtdArray = mtd.readAll(); xloaderStream.writeRawData(mtdArray, 0x3A00); // 14848 bytes mtd.seek(0x3A00 + 0x600); mtdArray = mtd.readAll(); secondaryStream.writeRawData(mtdArray, 0x1AB80); // 109440 bytes mtd.close(); xloader.close(); secondary.close(); return true; }
QString GazeboSimManager::stopRoverNode( QString rover_name ) { if (rover_processes.find(rover_name) == rover_processes.end()) return "Could not stop " + rover_name + " rover process since it does not exist."; rover_processes[rover_name]->terminate(); rover_processes[rover_name]->waitForFinished(); rover_processes.erase(rover_name); // Kill nodes QString argument = "rosnode kill "+rover_name+"_MOBILITY"; QProcess sh; sh.start("sh", QStringList() << "-c" << argument); sh.waitForFinished(); QString output = sh.readAll(); sh.close(); argument = "rosnode kill "+rover_name+"_NAVSAT"; sh.start("sh", QStringList() << "-c" << argument); sh.waitForFinished(); output += "<br>" + sh.readAll(); sh.close(); argument = "rosnode kill "+rover_name+"_TARGET"; sh.start("sh", QStringList() << "-c" << argument); sh.waitForFinished(); output += "<br>" + sh.readAll(); sh.close(); argument = "rosnode kill "+rover_name+"_OBSTACLE"; sh.start("sh", QStringList() << "-c" << argument); sh.waitForFinished(); output += "<br>" + sh.readAll(); sh.close(); argument = "rosnode kill "+rover_name+"_EKF"; sh.start("sh", QStringList() << "-c" << argument); sh.waitForFinished(); output += "<br>" + sh.readAll(); sh.close(); return output+"<br>rover process " + rover_name + " terminated along with <font color='green'>navsat, target, obstacle, and mobility</font> nodes"; }
bool OpenModelica::start(QString exeFile,QString &errMsg,int maxnsec) { QFileInfo exeFileInfo(exeFile); QString exeDir = exeFileInfo.absolutePath(); if(!QFile::exists(exeFile)) { errMsg = "Cannot find model executable file : " + exeFile; return false; } QProcess simProcess; simProcess.setWorkingDirectory(exeDir); #ifdef WIN32 QString appPath = "\""+exeFile+"\""; // add OM path in PATH QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QString omHome = env.value("OpenModelicaHome"); omHome = omHome+QDir::separator()+"bin"; QString mingw = env.value("OpenModelicaHome"); mingw = mingw+QDir::separator()+"MinGW"+QDir::separator()+"bin"; env.insert("PATH", env.value("Path") + ";"+omHome+";"+mingw); simProcess.setProcessEnvironment(env); //start process simProcess.start(appPath, QStringList()); #else QStringList arguments; arguments << "-c"; arguments << "./"+exeFileInfo.fileName() << " > log.txt"; simProcess.start("sh", arguments); #endif int nmsec; if(maxnsec==-1) nmsec = -1; else nmsec = maxnsec*1000; bool ok = simProcess.waitForFinished(nmsec); if(!ok) { errMsg = "Simulation process failed or time limit reached"; simProcess.close(); return false; } QString output(simProcess.readAllStandardOutput()); InfoSender::instance()->send(Info(output,ListInfo::OMCNORMAL2)); return ok; }
void MainWindow::on_Send_Eq_clicked() { QString program = Current_Path+"/send_eq"; QStringList arguments; QProcess *myProcess; myProcess = new QProcess(this); myProcess->start(program,arguments); myProcess->waitForStarted(); myProcess->waitForFinished(); myProcess->kill(); myProcess->close(); ui->textBrowser->setText("!#SUCCESS=Send Equalize!#"); }
/* * We need this to search for the SH process pid (which spaws yaourt) */ void ProcessWrapper::onSingleShot() { QProcess proc; QProcess pAux; QString saux; proc.start("ps -o pid -C sh"); proc.waitForFinished(-1); QString out = proc.readAll(); proc.close(); QStringList list = out.split("\n", QString::SkipEmptyParts); QStringList slist; for (int c=1; c<list.count(); c++) { int candidatePid = list.at(c).trimmed().toInt(); if (candidatePid < m_pidTerminal) continue; QString cmd = QString("ps --ppid %1").arg(candidatePid); proc.start(cmd); proc.waitForFinished(-1); QString out = proc.readAll(); if (out.contains("yaourt", Qt::CaseInsensitive)) { pAux.start("ps -o pid -C yaourt"); pAux.waitForFinished(-1); saux = pAux.readAll(); slist = saux.split("\n", QString::SkipEmptyParts); for (int d=1; d<slist.count(); d++) { int candidatePid2 = slist.at(d).trimmed().toInt(); if (candidatePid < candidatePid2) { m_pidSH = candidatePid; m_pidYaourt = candidatePid2; m_timer->start(); return; } } } } emit finishedTerminal(0, QProcess::NormalExit); }