本文整理汇总了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;
}
示例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
}
示例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());
}
示例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();
}
示例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;
}
示例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;
}
示例7: pid
Q_PID QProcessProto::pid() const
{
QProcess *item = qscriptvalue_cast<QProcess*>(thisObject());
if (item)
return item->pid();
return Q_PID();
}
示例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);
}
示例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();
}
}
示例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();
}
示例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));
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}