当前位置: 首页>>代码示例>>C++>>正文


C++ QProcess::pid方法代码示例

本文整理汇总了C++中QProcess::pid方法的典型用法代码示例。如果您正苦于以下问题:C++ QProcess::pid方法的具体用法?C++ QProcess::pid怎么用?C++ QProcess::pid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QProcess的用法示例。


在下文中一共展示了QProcess::pid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: startProcess

/*
 * Initialize and launch process object
 */
bool AbstractTool::startProcess(QProcess &process, const QString &program, const QStringList &args)
{
    static AssignProcessToJobObjectFun AssignProcessToJobObjectPtr = NULL;

    QMutexLocker lock(m_mutex_startProcess);
    emit messageLogged(commandline2string(program, args) + "\n");

    QProcessEnvironment env = process.processEnvironment();
    if(env.isEmpty()) env = QProcessEnvironment::systemEnvironment();
    env.insert("TEMP", QDir::toNativeSeparators(lamexp_temp_folder2()));
    env.insert("TMP", QDir::toNativeSeparators(lamexp_temp_folder2()));
    process.setProcessEnvironment(env);

    if(!AssignProcessToJobObjectPtr)
    {
        QLibrary Kernel32Lib("kernel32.dll");
        AssignProcessToJobObjectPtr = (AssignProcessToJobObjectFun) Kernel32Lib.resolve("AssignProcessToJobObject");
    }

    process.setProcessChannelMode(QProcess::MergedChannels);
    process.setReadChannel(QProcess::StandardOutput);
    process.start(program, args);

    if(process.waitForStarted())
    {

        if(AssignProcessToJobObjectPtr)
        {
            AssignProcessToJobObjectPtr(m_handle_jobObject, process.pid()->hProcess);
        }
        if(!SetPriorityClass(process.pid()->hProcess, BELOW_NORMAL_PRIORITY_CLASS))
        {
            SetPriorityClass(process.pid()->hProcess, IDLE_PRIORITY_CLASS);
        }

        lock.unlock();

        if(m_firstLaunch)
        {
            emit statusUpdated(0);
            m_firstLaunch = false;
        }

        return true;
    }

    emit messageLogged("Process creation has failed :-(");
    QString errorMsg= process.errorString().trimmed();
    if(!errorMsg.isEmpty()) emit messageLogged(errorMsg);

    process.kill();
    process.waitForFinished(-1);
    return false;
}
开发者ID:arestarh,项目名称:LameXP,代码行数:57,代码来源:Tool_Abstract.cpp

示例2: ProcessID

int ProcessID(QProcess const& process)
{
#ifdef Q_OS_WIN32
   _PROCESS_INFORMATION* pi(process.pid());
   if (pi) {
      return pi->dwProcessId;
   }else {
      return 0;
   }
#else
   return process.pid();
#endif
}
开发者ID:jlane-waikato,项目名称:IQmol,代码行数:13,代码来源:SystemDependent.C

示例3: launch

void ProcessLauncherHelper::launch(WebKit::ProcessLauncher* launcher)
{
    QString applicationPath = "%1 %2";

    if (QFile::exists(QCoreApplication::applicationDirPath() + "/QtWebProcess")) {
        applicationPath = applicationPath.arg(QCoreApplication::applicationDirPath() + "/QtWebProcess");
    } else {
        applicationPath = applicationPath.arg("QtWebProcess");
    }

    QString program(applicationPath.arg(m_server.serverName()));

    QProcess* webProcess = new QProcess();
    webProcess->setProcessChannelMode(QProcess::ForwardedChannels);
    webProcess->start(program);

    if (!webProcess->waitForStarted()) {
        qDebug() << "Failed to start" << program;
        ASSERT_NOT_REACHED();
        delete webProcess;
        return;
    }

    setpriority(PRIO_PROCESS, webProcess->pid(), 10);

    m_items.append(WorkItem::create(launcher, &WebKit::ProcessLauncher::didFinishLaunchingProcess, webProcess, m_server.serverName()).leakPtr());
}
开发者ID:,项目名称:,代码行数:27,代码来源:

示例4: getEnvPath

  QString ddMainWindow::getEnvPath(int type)
  {
      QString env = "";

      switch (type)
      {
        case eSDCARD: env = "$EXTERNAL_STORAGE";
          break;
        case eDATA: env = "$ANDROID_DATA";
          break;

      case eSDCARD_EXT: env = "$EXTERNAL_STORAGE2";
        break;


      }


      QProcess proc;
      QString cmd = "adb";
      QStringList argAdb;
      argAdb << "shell" << "echo" << env ;
      proc.start(cmd, argAdb);
      qDebug() <<  " pid =" << proc.pid() << " process started"  ;
      if (!proc.waitForFinished())
          return false;

      QByteArray res = proc.readLine();

      return res.trimmed();

  }
开发者ID:vohulg,项目名称:kaltas_src,代码行数:32,代码来源:ddmainwindow.cpp

示例5: getPathSdcardFromLink

// получаем путь к точке монтирования sdcard, так как на многоих моделях в корне лежит ссылка на точку монтирования
  // карты памяти,
  QString ddMainWindow::getPathSdcardFromLink()
  {
      QString sdcardPath = "";
      sdcardPath.clear();

      QProcess proc;
      QString cmd = "adb";
      QStringList argAdb;
      argAdb << "shell" << "ls" << "-l" << sdcardFolder  ;
      proc.start(cmd, argAdb);
      qDebug() <<  " pid =" << proc.pid() << " process started"  ;
      if (!proc.waitForFinished())
          return false;

      QByteArray res = proc.readLine();
      if (res.isEmpty())
          return sdcardPath;

     // если не начинается на 'l' значит это не ссылка и возвращаем пустую строку
      if (!res.startsWith("l"))
          return sdcardPath;

          sdcardPath = res;

          QStringList list = sdcardPath.split(" ");

          int indexPath = list.size() - 1;
          sdcardPath = list.at(indexPath).trimmed();

    return sdcardPath;

  }
开发者ID:vohulg,项目名称:kaltas_src,代码行数:34,代码来源:ddmainwindow.cpp

示例6: runCallgrindSubProcess

// Reruns this program through callgrind, storing callgrind result files in the
// current directory.
// Returns \c true upon success, otherwise false.
bool QBenchmarkValgrindUtils::runCallgrindSubProcess(const QStringList &origAppArgs, int &exitCode)
{
    const QString execFile(origAppArgs.at(0));
    QStringList args;
    args << QLatin1String("--tool=callgrind") << QLatin1String("--instr-atstart=yes")
         << QLatin1String("--quiet")
         << execFile << QLatin1String("-callgrindchild");

    // pass on original arguments that make sense (e.g. avoid wasting time producing output
    // that will be ignored anyway) ...
    for (int i = 1; i < origAppArgs.size(); ++i) {
        const QString arg(origAppArgs.at(i));
        if (arg == QLatin1String("-callgrind"))
            continue;
        args << arg; // ok to pass on
    }

    QProcess process;
    process.start(QLatin1String("valgrind"), args);
    process.waitForStarted(-1);
    QBenchmarkGlobalData::current->callgrindOutFileBase =
        QBenchmarkValgrindUtils::outFileBase(process.pid());
    const bool finishedOk = process.waitForFinished(-1);
    exitCode = process.exitCode();

    dumpOutput(process.readAllStandardOutput(), stdout);
    dumpOutput(process.readAllStandardError(), stderr);

    return finishedOk;
}
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:33,代码来源:qbenchmarkvalgrind.cpp

示例7: pid

Q_PID QProcessProto::pid() const
{
  QProcess *item = qscriptvalue_cast<QProcess*>(thisObject());
  if (item)
    return item->pid();
  return Q_PID();
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例8: on_btnStart_clicked

void MainWindow::on_btnStart_clicked()
{
    if (!QFile(programPath).exists()) {
        QMessageBox::warning(this,
                             tr("Невозможно запустить процесс"),
                             tr("Не найден файл программы.\n"
                                "Возможно, не указан путь к файлу gostunnel.exe"));
        return;
    }
    if (ui->lwGroups->count() == 0) {
        return;
    }
    QString el = ui->lwGroups->currentItem()->text();
    QProcess *proc = connections.value(el);
    if (proc->pid() <= 0) {
        QDir wd = QDir(programPath);
        wd.cdUp();
        proc->setWorkingDirectory(wd.path());
        QStringList args;
        args << "--config" << programConfig
             << "-s" << el;
        connect(proc, SIGNAL(error(QProcess::ProcessError)),
                this, SLOT(processError(QProcess::ProcessError)));
        connect(proc, SIGNAL(finished(int,QProcess::ExitStatus)),
                this, SLOT(processFinished(int,QProcess::ExitStatus)));
        connect(proc, SIGNAL(stateChanged(QProcess::ProcessState)),
                this, SLOT(processStateChenged(QProcess::ProcessState)));
        connect(proc, SIGNAL(readyReadStandardError()),
                this, SLOT(processReadyReadError()));
        connect(proc, SIGNAL(started()),
                this, SLOT(processStarted()));
        ui->lwGroups->currentItem()->setBackgroundColor(QColor::fromRgb(255, 233, 113));
        proc->start(programPath, args);
    }
开发者ID:w3tl,项目名称:gostunnel,代码行数:34,代码来源:mainwindow.cpp

示例9: kill

  void LocalProcess::kill(QProcess &t_process, bool t_force)
  {
    if (t_process.state() == QProcess::Running)
    {
#ifdef Q_WS_WIN
      PROCESS_INFORMATION *pinfo = (PROCESS_INFORMATION*)t_process.pid();
      if (pinfo)
      {
        QString abort_cmd;
        LOG(Info, "Killing process tree using taskkill " << pinfo->dwProcessId << " force " << t_force);
        if (t_force)
        {
          abort_cmd = QString("taskkill /PID %1 /T /F").arg(pinfo->dwProcessId);
        } else {
          abort_cmd = QString("taskkill /PID %1 /T").arg(pinfo->dwProcessId);
        }
        QProcess::execute(abort_cmd);
      } 
#else
      pid_t pid(t_process.pid());

      if (pid > 0)
      {
        openstudio::path killtree = openstudio::getSharedResourcesPath()/openstudio::toPath("runmanager")/openstudio::toPath("killtree.sh");
        LOG(Info, "Killing process tree using killtree" << openstudio::toString(killtree) << " for pid " << pid << " force " << t_force);

        QStringList qsl;
        qsl.push_back(QString::number(pid));
        if (t_force)
        {
          qsl.push_back(QString::number(SIGKILL));
        } else {
          qsl.push_back(QString::number(SIGTERM));
        }
        QProcess::execute(openstudio::toQString(killtree), qsl);
      }
#endif
    }

    if (t_force)
    {
      t_process.kill();
    } else {
      t_process.terminate();
    }

  }
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:47,代码来源:LocalProcess.cpp

示例10: cliOut

QString ignsystem::cliOut(const QString& cli){
    QProcess os;
    os.setProcessChannelMode(QProcess::MergedChannels);
    os.start(cli);
    int pid = os.pid();
    qDebug() << "Executing process with PID" << pid;
    os.waitForFinished(-1);
    return os.readAllStandardOutput();
}
开发者ID:aksaramaya,项目名称:ignsdk-qt,代码行数:9,代码来源:ignsystem.cpp

示例11: onHelperProcessStarted

void OverlayPrivateWin::onHelperProcessStarted() {
	QProcess *helper = qobject_cast<QProcess *>(sender());
	QString path;
	if (helper == m_helper_process) {
		path = m_helper_exe_path;
	} else if (helper == m_helper64_process) {
		path = m_helper64_exe_path;
	} else {
		qFatal("OverlayPrivateWin: unknown QProcess found in onHelperProcessStarted().");
	}

	PROCESS_INFORMATION *pi = helper->pid();
	qWarning("OverlayPrivateWin: overlay helper process '%s' started with PID %llu.",
	         qPrintable(path), static_cast<unsigned long long>(pi->dwProcessId));
}
开发者ID:AceXare,项目名称:mumble,代码行数:15,代码来源:Overlay_win.cpp

示例12: spawnChildClient

void AssignmentClientMonitor::spawnChildClient() {
    QProcess *assignmentClient = new QProcess(this);
    
    _childProcesses.append(QPointer<QProcess>(assignmentClient));
    
    // make sure that the output from the child process appears in our output
    assignmentClient->setProcessChannelMode(QProcess::ForwardedChannels);
    
    assignmentClient->start(applicationFilePath(), _childArguments);
    
    // link the child processes' finished slot to our childProcessFinished slot
    connect(assignmentClient, SIGNAL(finished(int, QProcess::ExitStatus)), this,
            SLOT(childProcessFinished(int, QProcess::ExitStatus)));
    
    qDebug() << "Spawned a child client with PID" << assignmentClient->pid();
}
开发者ID:RyanDowne,项目名称:hifi,代码行数:16,代码来源:AssignmentClientMonitor.cpp

示例13: init

void Frame::init(QString pro)
{
    QProcess *p;
    p = new QProcess();
    p->start(pro);
    c_pid = p->pid();
    qDebug()<<c_pid;
    XWindowFinder *finder;
    finder = new XWindowFinder(c_pid);
    while(!finder->findresult()){
        delete finder;
        finder = new XWindowFinder(c_pid);
    }
    finder->print();
    std::vector<Window> tt;
    tt = finder->result();
    std::vector<Window>::iterator hehe = tt.begin();
    c_win = *hehe;
}
开发者ID:yqsz242,项目名称:QtDesktop,代码行数:19,代码来源:frame.cpp

示例14: launch

// internal launch function
int launch(const QString &cmd)
{
    QProcess *proc = new QProcess();
    proc->start(cmd);
    proc->waitForStarted();
    startedProcesses << proc;
    _PROCESS_INFORMATION *_pid = proc->pid();
    int pid = _pid ? _pid->dwProcessId : 0;
    if (verbose) {
        fprintf(stderr, "%s", proc->readAllStandardError().constData());
        fprintf(stderr, "%s", proc->readAllStandardOutput().constData());
    }
    if (pid) {
        if (verbose) {
            fprintf(stderr, "kdeinit5: Launched %s, pid = %ld\n", qPrintable(cmd), (long) pid);
        }
    } else {
        if (verbose) {
            fprintf(stderr, "kdeinit5: could not launch %s, exiting\n", qPrintable(cmd));
        }
    }
    return pid;
}
开发者ID:KDE,项目名称:kinit,代码行数:24,代码来源:kinit_win.cpp

示例15: runCallgrindSubProcess

// Reruns this program through callgrind, storing callgrind result files in the
// current directory.
// Returns true upon success, otherwise false.
bool QBenchmarkValgrindUtils::runCallgrindSubProcess(const QStringList &origAppArgs, int &exitCode)
{
    const QString execFile(origAppArgs.at(0));
    QStringList args;
    args << QLatin1String("--tool=callgrind") << QLatin1String("--instr-atstart=yes")
         << QLatin1String("--quiet")
         << execFile << QLatin1String("-callgrindchild");

#if (defined Q_WS_QWS)
    // While running the child process, we aren't processing events, and hence aren't
    // acting as the QWS server. Therefore it's necessary to tell the child to act
    // as its own server instead of connecting to us.
    args << QLatin1String("-qws");
#endif

    // pass on original arguments that make sense (e.g. avoid wasting time producing output
    // that will be ignored anyway) ...
    for (int i = 1; i < origAppArgs.size(); ++i) {
        const QString arg(origAppArgs.at(i));
        if (arg == QLatin1String("-callgrind"))
            continue;
        args << arg; // ok to pass on
    }

    QProcess process;
    process.start(QLatin1String("valgrind"), args);
    process.waitForStarted(-1);
    QBenchmarkGlobalData::current->callgrindOutFileBase =
        QBenchmarkValgrindUtils::outFileBase(process.pid());
    const bool finishedOk = process.waitForFinished(-1);
    exitCode = process.exitCode();

    dumpOutput(process.readAllStandardOutput(), stdout);
    dumpOutput(process.readAllStandardError(), stderr);

    return finishedOk;
}
开发者ID:BGmot,项目名称:Qt,代码行数:40,代码来源:qbenchmarkvalgrind.cpp


注:本文中的QProcess::pid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。