void SmbView::setOpen(QListViewItem *item, bool on) { if(on && item->childCount() == 0) { if(item->depth() == 0) { // opening group m_current = item; *m_proc << "nmblookup" + m_wins_server + "-M "; *m_proc << KProcess::quote(item->text(0)); *m_proc << " -S | grep '<20>' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*<20>.*//' | xargs -Iserv_name smbclient -N -L 'serv_name' -W "; *m_proc << KProcess::quote(item->text(0)); *m_proc << " -A "; *m_proc << KProcess::quote(m_passwdFile->name()); startProcess(ServerListing); } else if(item->depth() == 1) { // opening server m_current = item; *m_proc << "smbclient -N -L "; *m_proc << KProcess::quote(item->text(0)); *m_proc << " -W "; *m_proc << KProcess::quote(item->parent()->text(0)); *m_proc << " -A "; *m_proc << KProcess::quote(m_passwdFile->name()); startProcess(ShareListing); } } QListView::setOpen(item, on); }
int main(int argc, const char * argv[]) { int toFirst[2], fromFirst[2]; int toSecond[2], fromSecond[2]; if (argc != 3) // User didn't specify enough arguments, exit program. { std::cout << "Usage: " << argv[0] << " cmd1 cmd2" << std::endl; exit(1); } if (pipe(toFirst) == -1 || pipe(fromFirst) == -1 || pipe(toSecond) == -1 || pipe(fromSecond) == -1) { std::cerr << "Failed to pipe"; exit(EXIT_FAILURE); } startProcess(toFirst, fromFirst, argv[1]); startProcess(toSecond, fromSecond, argv[2]); /* Piping complete, start main program */ return 0; }
int main(int argc, char** argv) { gettimeofday(&start, NULL); std::ifstream file ("outputFile.txt"); std::string line; std::vector< std::string > lines; std::vector<PageTable*> page_tables; int page_faults = 0; TLB tlb; bool useTLB = (argc > 1 && strcmp(argv[1], "-t") == 0); while (getline(file, line)){ if (useTLB){ switch(line[0]){ case 'S': startProcess(page_tables, std::stoi(split(line)[1]), std::stoi(split(line)[2])); break; case 'R': page_faults += referenceTLB(page_tables, tlb, std::stoi(split(line)[1]), std::stoi(split(line)[2])); break; case 'T': terminateProcess(page_tables, std::stoi(split(line)[1])); break; } }else{ switch(line[0]){ case 'S': startProcess(page_tables, std::stoi(split(line)[1]), std::stoi(split(line)[2])); break; case 'R': page_faults += referenceNoTLB(page_tables, tlb, std::stoi(split(line)[1]), std::stoi(split(line)[2])); break; case 'T': terminateProcess(page_tables, std::stoi(split(line)[1])); break; } } } std::cout << "Num Page Faults: " << page_faults << std::endl; gettimeofday(&end, NULL); std::cout << "Elapsed Time: " << ((end.tv_sec - start.tv_sec) * 1000 + ((end.tv_usec - start.tv_usec)/1000.0) + 0.5) << "ms" << std::endl; file.close(); return 0; }
ScanManager::ScanManager(MemStorage *memStor, QObject *parent) : QObject(parent) { scanner = new PLCScanner(); scanner->moveToThread(&scanThread); connect(&scanThread,SIGNAL(finished()),scanner,SLOT(deleteLater())); connect(this,SIGNAL(startProcess()),scanner,SLOT(scanProcess())); connect(scanner,SIGNAL(updateBlock(QString,int,QByteArray)),memStor,SLOT(updateBlock(QString,int,QByteArray))); connect(scanner,SIGNAL(updateCorrectRequestCnt(int)),this,SLOT(updCorrAnswerCnt(int))); connect(scanner,SIGNAL(updateErrorRequestCnt(int)),this,SLOT(updErrAnswerCnt(int))); connect(scanner,SIGNAL(addMessage(QString)),this,SIGNAL(addMessage(QString))); connect(scanner,SIGNAL(errMessage(QString)),this,SIGNAL(errMessage(QString))); connect(scanner,SIGNAL(updateTimeStr(QString)),this,SIGNAL(updateTimeStr(QString))); scanThread.start(); emit startProcess(); }
/** * Startup method for the module */ void PCAPExporterPipe::performStart() { time(&last_check); if(last_check == (time_t) -1) THROWEXCEPTION("time() failed"); registerSignalHandlers(); msg(MSG_INFO, "Started PCAPExporterPipe with the following parameters:"); if (fifoReaderCmd != ""){ msg(MSG_INFO, " - fifoReaderCmd = %s", fifoReaderCmd.c_str()); msg(MSG_INFO, " - fifoReaderPid = %d", fifoReaderPid); } else { THROWEXCEPTION("No fifoReaderCmd specified!"); } if (logFileName != ""){ msg(MSG_INFO, " - logfileBaseName = %s", logFileName.c_str()); msg(MSG_INFO, " - appenddate = %s", appenddate ? "true" : "false"); } else msg(MSG_ERROR, "No Logfile specified - dumping to stdout!"); msg(MSG_INFO, " - sigKillTimeout = %d" , sigKillTimeout); msg(MSG_INFO, " - restartInterval = %u ms" , restartInterval); startProcess(); }
void JabberBrowser::loadItem(QListViewItem *item) { bool bProcess = false; unsigned mode = atol(item->text(COL_MODE).latin1()); if (m_client->getBrowseType() & BROWSE_DISCO){ if (((mode & BROWSE_DISCO) == 0) && item->text(COL_ID_DISCO_ITEMS).isEmpty()){ item->setText(COL_ID_DISCO_ITEMS, m_client->discoItems(item->text(COL_JID).utf8(), item->text(COL_NODE).utf8()).c_str()); mode |= BROWSE_DISCO; bProcess = true; } if (((mode & BROWSE_INFO) == 0) && item->text(COL_ID_DISCO_INFO).isEmpty()){ item->setText(COL_ID_DISCO_INFO, m_client->discoInfo(item->text(COL_JID).utf8(), item->text(COL_NODE).utf8()).c_str()); mode |= BROWSE_INFO; bProcess = true; } } if (m_client->getBrowseType() & BROWSE_BROWSE){ if (((mode & BROWSE_BROWSE) == 0) && item->text(COL_ID_BROWSE).isEmpty() && haveFeature("iq:id:browse", item->text(COL_FEATURES))){ item->setText(COL_ID_BROWSE, m_client->browse(item->text(COL_JID).utf8()).c_str()); mode |= BROWSE_BROWSE; bProcess = true; } } item->setText(COL_MODE, QString::number(mode)); if (!m_bInProcess && bProcess){ m_bInProcess = true; startProcess(); } }
void BatchProcessImagesDialog::slotProcessStart() { if (m_selectedImageFiles.isEmpty() == true) return; if (m_ui->m_removeOriginal->isChecked() == true) { if (KMessageBox::warningContinueCancel(this, i18n( "All original image files will be removed from the source Album.\nDo you want to continue?"), i18n("Delete Original Image Files"), KStandardGuiItem::cont(), KStandardGuiItem::cancel(), "KIPIplugin-BatchProcessImages-AlwaysRemomveOriginalFiles") != KMessageBox::Continue) return; } m_convertStatus = UNDER_PROCESS; disconnect(this, SIGNAL(user1Clicked()), this, SLOT(slotProcessStart())); showButton(KDialog::Cancel, false); setButtonText(User1, i18n("&Stop")); connect(this, SIGNAL(user1Clicked()), this, SLOT(slotProcessStop())); enableWidgets(false); m_ui->m_progress->setVisible(true); m_ui->m_progress->progressScheduled(i18n("Batch Image Effects"), true, true); m_ui->m_progress->progressThumbnailChanged(KIcon("kipi").pixmap(22, 22)); m_listFile2Process_iterator = new QTreeWidgetItemIterator(m_listFiles); startProcess(); }
void MainWidget::setupClicked() { if (ui->setupName->text().isEmpty()) { return; } QProcess *process = createProcess(); QStringList args; args << "setup"; if (!ui->setupNem->text().isEmpty()) { args << "--nem" << ui->setupNem->text(); } if (!ui->setupCurse->text().isEmpty()) { args << "--curse" << ui->setupCurse->text(); } if (!ui->setupServer->text().isEmpty()) { args << "--server" << ui->setupServer->text(); } args << ui->setupName->text(); process->setArguments(args); startProcess(process); }
/* Called by "Start" used while OCR is not in progress */ void OcrEngine::startOCRProcess() { if (m_ocrDialog==NULL) return; m_ocrResultText = ""; startProcess(m_ocrDialog, &m_introducedImage); }
bool FileProjections::loadProjection(Projection *pr) { if (!pr) return false; unsigned id = pr->getId(); ProjectionsReader reader(*this); startProcess(&reader, 0u, pr->getEccentricity()); std::string prName(graphFileName); prName += "_pr_"; prName += std::to_string(id); prName += ".txt"; ProjectionsReader::Type typeId; bool result = false; FILE* f = reader.openFile(prName.data(), typeId); if (f) { result = reader.readProjections(f, typeId); fclose(f); } lastError = reader.getLastError(); completeProcess(); return result; }
bool Worker::restart() { numFailures++; if (numFailures >= maxFailures) { Logger::error << "Max worker failures ('" << maxFailures << "') reached, can't recover." << endl; throw WorkerException("SVS script error, can't recover, contact administrator.", false); } Logger::warning << "trying to restart worker" << endl; terminateProcess(); bool ok = startProcess(); if (!ok) { return false; } ok = sendSession(); if (!ok) { terminateProcess(); return false; } return true; }
void PingThread::doWork() { //qDebug() << "do work"; QRegExp regex(".*time=([0-9.]+) ms$"); while (process->canReadLine()) { QString line = QString(process->readLine()).trimmed(); // qDebug() << "Read line: " << line; if (regex.exactMatch(line)) { //qDebug() << "Match: " << regex.capturedTexts()[1]; bool conv = false; lastPing = regex.capturedTexts()[1].toFloat(&conv); if (!conv) lastPing = std::numeric_limits<float>::quiet_NaN(); } else { qDebug() << "No match"; // lastPing = std::numeric_limits<float>::quiet_NaN(); } } if (this->process->state() == QProcess::NotRunning) { qDebug() << "at end"; startProcess(); } }
/* virtual */ void DDZeroOut::exec() { kDebug(KFAREA) << k_funcinfo ; if ( deviceName.isEmpty() ) { emit status( i18n("Internal error: device not correctly defined."), -1 ); emit done( this, false ); return; } if ( m_ddName.isEmpty() ) { emit status( i18n("Cannot find dd."), -1 ); emit done( this, false ); return; } delete theProcess; theProcess = new KProcess; *theProcess << m_ddName ; *theProcess << QStringLiteral( "if=/dev/zero" ) ; *theProcess << QStringLiteral( "of=" )+deviceName; if ( !startProcess() ) { emit status( i18n("Could not start dd."), -1 ); emit done( this, false ); } }
bool Worker::startint() { WriteLocker locker(&mutex); if (status == WORKER_RUNNING) { return true; } bool ok = startProcess(); if (!ok) { return false; } ok = sendSession(); if (!ok) { terminateProcess(); return false; } started = true; return true; }
void UFSFilesystem::exec() { DEBUGSETUP; if ( deviceName.isEmpty() ) { emit status( i18n("Internal error: device not correctly defined."), -1 ); emit done(this,false); return; } if (newfs.isEmpty()) { emit status(i18nc("BSD", "Cannot find a program to create UFS filesystems."),-1); emit done(this,false); return; } delete theProcess; KProcess *p = theProcess = new KProcess; *p << newfs; // ### TODO: is it still needed? (FreeBSD 5.3's man page says: "For backward compatibility.") if ( deviceInfo ) *p << "-T" << QString("fd%1").arg(deviceInfo->blocks); *p << deviceName; if (!startProcess()) { emit status(i18nc("BSD", "Cannot start UFS format program."),-1); emit done(this,false); } }
/** * Startup method for the module */ void PCAPExporterPipe::performStart() { char errbuf[PCAP_ERRBUF_SIZE]; time(&last_check); if(last_check == (time_t) -1) THROWEXCEPTION("time() failed"); SignalHandler::getInstance().registerSignalHandler(SIGCHLD, this); SignalHandler::getInstance().registerSignalHandler(SIGPIPE, this); if(restartOnSignal) SignalHandler::getInstance().registerSignalHandler(SIGUSR2, this); dummy = pcap_open_dead(link_type, snaplen); if (!dummy) { THROWEXCEPTION("Could not open dummy device: %s", errbuf); } startProcess(); msg(MSG_INFO, "Started PCAPExporterPipe with the following parameters:"); if (fifoReaderCmd != ""){ msg(MSG_INFO, " - fifoReaderCmd = %s", fifoReaderCmd.c_str()); msg(MSG_INFO, " - fifoReaderPid = %d", fifoReaderPid); } else { THROWEXCEPTION("No fifoReaderCmd specified!"); } if (logFileName != ""){ msg(MSG_INFO, " - logfileBaseName = %s", logFileName.c_str()); msg(MSG_INFO, " - appenddate = %s", appenddate ? "true" : "false"); } else msg(MSG_ERROR, "No Logfile specified - dumping to stdout!"); msg(MSG_INFO, " - sigKillTimeout = %d" , sigKillTimeout); }
/** * Handles SIGCHLD and tries to restart the external process. * If this fails too often within a short time period, we assume that * something went terribly wrong and throw an exception accordingly. */ void PCAPExporterPipe::handleSigChld(int sig) { if(onRestart || exitFlag || isRunning(fifoReaderPid)) return; onRestart = true; counter++; time_t tmp; time(&tmp); if(tmp== (time_t) -1) THROWEXCEPTION("time() failed"); // reset the counter if the last restart was more than 5 seconds ago if((tmp -last_check) > 5) counter = 0; if(counter > 5 && (tmp - last_check ) < 5) THROWEXCEPTION("Too many restarts in a short time period. Maybe your commandline is erroneous"); if(!isRunning(fifoReaderPid)){ //waitpid(fifoReaderPid, NULL, 0); msg(MSG_ERROR, "Process of fifoReaderCmd \'%s\' with fifoReaderPid %d is not running!", fifoReaderCmd.c_str(), fifoReaderPid); startProcess(); } time(&last_check); if(last_check == (time_t) -1) THROWEXCEPTION("time() failed"); onRestart = false; }
void MinixFilesystem::exec() { DEBUGSETUP; if ( deviceName.isEmpty() ) { emit status( i18n("Internal error: device not correctly defined."), -1 ); emit done(this,false); return; } if (newfs.isEmpty()) { emit status(i18n("Cannot find a program to create Minix filesystems."),-1); emit done(this,false); return; } delete theProcess; KProcess *p = theProcess = new KProcess; *p << newfs; // Labeling is not possible if (doVerify) *p << QStringLiteral( "-c" ) ; *p << deviceName ; if (!startProcess()) { emit status(i18n("Cannot start Minix format program."),-1); emit done(this,false); } }
ScriptResolver::ScriptResolver( const QString& exe ) : Tomahawk::ExternalResolverGui( exe ) , m_num_restarts( 0 ) , m_msgsize( 0 ) , m_ready( false ) , m_stopped( true ) , m_configSent( false ) , m_deleting( false ) , m_error( Tomahawk::ExternalResolver::NoError ) { tLog() << Q_FUNC_INFO << "Created script resolver:" << exe; connect( &m_proc, SIGNAL( readyReadStandardError() ), SLOT( readStderr() ) ); connect( &m_proc, SIGNAL( readyReadStandardOutput() ), SLOT( readStdout() ) ); connect( &m_proc, SIGNAL( finished( int, QProcess::ExitStatus ) ), SLOT( cmdExited( int, QProcess::ExitStatus ) ) ); startProcess(); if ( !TomahawkUtils::nam() ) return; // set the name to the binary, if we launch properly we'll get the name the resolver reports m_name = QFileInfo( filePath() ).baseName(); // set the icon, if we launch properly we'll get the icon the resolver reports m_icon = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultResolver, TomahawkUtils::Original, QSize( 128, 128 ) ); }
void MainWindow::xyzClicked() { QStringList files = QFileDialog::getOpenFileNames(this, tr("Select Image Files"), QString(), tr("Images (*.xyz *.png *.bmp)")); if (files.isEmpty()) return; startProcess(xyzPath, files); }
bool Worker::startProcess() { readPosition = 0; readBuffer.clear(); int pipe_server_to_child[2]; int pipe_child_to_server[2]; bool ok = createPipes(pipe_server_to_child, pipe_child_to_server); if (!ok) { status = WORKER_NOT_RUNNING; return false; } ok = startProcess(executable, args, pipe_server_to_child, pipe_child_to_server); if (!ok) { status = WORKER_NOT_RUNNING; return false; } status = WORKER_RUNNING; return true; }
void LSession::start(){ //First check for a valid installation if( !LUtils::isValidBinary("fluxbox") || !LUtils::isValidBinary("lumina-desktop") ){ exit(1); } //Window Manager First // FLUXBOX BUG BYPASS: if the ~/.fluxbox dir does not exist, it will ignore the given config file //if(!QFile::exists(QDir::homePath()+"/.fluxbox")){ QDir dir; dir.mkpath(QDir::homePath()+"/.fluxbox"); } //startProcess("wm", "fluxbox -rc "+QDir::homePath()+"/.lumina/fluxbox-init -no-slit -no-toolbar"); //Desktop Next startProcess("runtime","lumina-desktop"); //ScreenSaver if(LUtils::isValidBinary("xscreensaver")){ startProcess("screensaver","xscreensaver -no-splash"); } //Compositing manager if(LUtils::isValidBinary("xcompmgr")){ startProcess("compositing","xcompmgr"); } }
// perform different tasks based on the words read in from the terminal int processWords(char* words[100]) { if(!strcmp(words[0], "quit") || !strcmp(words[0], "exit")) { return 0; } else if(!strcmp(words[0], "start")) { startProcess(words[1], &words[1]); } else if(!strcmp(words[0], "wait")) { waitProcess(); } else if(!strcmp(words[0], "run")) { runProcess(words[1], &words[1]); } else if(!strcmp(words[0], "kill")) { // send 0 into second argument to kill if(!words[1]) { // no argument printf("myshell: command \"kill\" requires a pid as an argument\n"); } else { killProcess(atoi(words[1]), 0); } } else if(!strcmp(words[0], "stop")) { // send 1 into second argument to stop if(!words[1]) { // no argument printf("myshell: command \"stop\" requires a pid as an argument\n"); } else { killProcess(atoi(words[1]), 1); } } else if(!strcmp(words[0], "continue")) { // send 2 into second argument to continue if(!words[1]) { // no argument printf("myshell: command \"continue\" requires a pid as an argument\n"); } else { killProcess(atoi(words[1]), 2); } } else { printf("myshell: unknown command: %s\n", words[0]); } return 1; }
Launcher::Launcher(int numImages, int numThreads, QString workerCommand, QStringList args) : runningProcs(0), timer(this),workCmd(workerCommand),procCount(1),workArgs(args) { if(numThreads > numImages) numThreads = numImages;// more threads than images are useless! int iPerThread = numImages / numThreads; //we roud down here as we use ints for(int i = 0; i < (numThreads - 1); i++){ startProcess(i*iPerThread, iPerThread); } startProcess((numThreads -1)*iPerThread, numImages - (numThreads -1)*iPerThread); connect(&timer,SIGNAL(timeout()),this,SLOT(printProgress())); timer.setInterval(100); timer.start(); }
void GxsIdRSTreeWidgetItem::startProcess() { if (mRetryWhenFailed) { disconnect(rApp, SIGNAL(minuteTick()), this, SLOT(startProcess())); } GxsIdDetails::process(mId, fillGxsIdRSTreeWidgetItemCallback, this); }
void ConnectionClient::restartProcess() { finishProcess(); startProcess(); connectToServer(); emit processRestarted(); }
PingThread::PingThread(QObject * const parent, QString *host) : QObject(parent), process(NULL), timer(new QTimer(this)), host(*host) { this->lastPing = std::numeric_limits<float>::quiet_NaN(); startProcess(); connect(timer, SIGNAL(timeout()), this, SLOT(doWork())); timer->start(1000); qDebug() << "thread started"; }
void GxsIdRSTreeWidgetItem::processResult(bool success) { mIdFound = success; if (!mIdFound && mRetryWhenFailed) { /* Try again */ connect(rApp, SIGNAL(minuteTick()), this, SLOT(startProcess())); } }
void Actions::openUrl(const QUrl &url) { if (qApp->settings()->value("Program/UseCommonWebBrowser", true).toBool()) { QDesktopServices::openUrl(url); } else { QString browser = qApp->settings()->value("Program/WebBrowser").toString(); startProcess(browser, QStringList(url.toString())); } }
void JabberBrowser::go(const QString &url, const QString &node) { setNavigation(); Command cmd; setTitle(); m_list->clear(); cmd->id = CmdBrowseInfo; cmd->flags = COMMAND_DISABLED; cmd->param = this; Event eNext(EventCommandDisabled, cmd); eNext.process(); cmd->id = CmdBrowseSearch; cmd->flags = COMMAND_DISABLED; cmd->param = this; eNext.process(); cmd->id = CmdRegister; cmd->flags = COMMAND_DISABLED; cmd->param = this; eNext.process(); cmd->id = CmdBrowseConfigure; cmd->flags = COMMAND_DISABLED; cmd->param = this; eNext.process(); m_bInProcess = true; QListViewItem *item = new QListViewItem(m_list); item->setText(COL_JID, url); item->setText(COL_NAME, url); item->setText(COL_NODE, node); m_bError = false; unsigned mode = 0; if (m_client->getBrowseType() & BROWSE_DISCO){ item->setText(COL_ID_DISCO_ITEMS, m_client->discoItems(url.utf8(), node.utf8()).c_str()); item->setText(COL_ID_DISCO_INFO, m_client->discoInfo(url.utf8(), node.utf8()).c_str()); mode = BROWSE_DISCO | BROWSE_INFO; } if (m_client->getBrowseType() & BROWSE_BROWSE){ if (node.isEmpty()){ item->setText(COL_ID_BROWSE, m_client->browse(url.utf8()).c_str()); mode |= BROWSE_BROWSE; } } item->setText(COL_MODE, QString::number(mode)); item->setPixmap(COL_NAME, Pict("empty")); cmd->id = CmdUrl; cmd->param = this; Event eWidget(EventCommandWidget, cmd); CToolCombo *cmbUrl = (CToolCombo*)(eWidget.process()); if (cmbUrl) cmbUrl->setText(url); cmd->id = CmdNode; CToolCombo *cmbNode = (CToolCombo*)(eWidget.process()); if (cmbNode) cmbNode->setText(node); startProcess(); if (item->text(COL_ID_DISCO_INFO).isEmpty()) stop(i18n("Client offline")); }