make sure AC process ID is valid before acting on the process
Showing the changes to assignment-client/src/AssignmentClientMonitor.cpp (1 of 1 file). Show all
Unified · Split
| @@ -94,8 +94,10 @@ void AssignmentClientMonitor::stopChildProcesses() { · 93 unmodified lines | ||
| 94 | 94 | |
| 95 | 95 | // ask child processes to terminate |
| 96 | 96 | foreach(QProcess* childProcess, _childProcesses) { |
| 97 | − qDebug() << "Attempting to terminate child process" << childProcess->processId(); | |
| 98 | − childProcess->terminate(); | |
| 97 | + if (childProcess->processId() > 0) { | |
| 98 | + qDebug() << "Attempting to terminate child process" << childProcess->processId(); | |
| 99 | + childProcess->terminate(); | |
| 100 | + } | |
| 99 | 101 | } |
| 100 | 102 | |
| 101 | 103 | simultaneousWaitOnChildren(WAIT_FOR_CHILD_MSECS); |
| @@ -103,8 +105,10 @@ void AssignmentClientMonitor::stopChildProcesses() { · 1 unmodified line | ||
| 103 | 105 | if (_childProcesses.size() > 0) { |
| 104 | 106 | // ask even more firmly |
| 105 | 107 | foreach(QProcess* childProcess, _childProcesses) { |
| 106 | − qDebug() << "Attempting to kill child process" << childProcess->processId(); | |
| 107 | − childProcess->kill(); | |
| 108 | + if (childProcess->processId() > 0) { | |
| 109 | + qDebug() << "Attempting to kill child process" << childProcess->processId(); | |
| 110 | + childProcess->kill(); | |
| 111 | + } | |
| 108 | 112 | } |
| 109 | 113 | |
| 110 | 114 | simultaneousWaitOnChildren(WAIT_FOR_CHILD_MSECS); |
| @@ -154,12 +158,14 @@ void AssignmentClientMonitor::spawnChildClient() { · 43 unmodified lines | ||
| 154 | 158 | assignmentClient->setProcessChannelMode(QProcess::ForwardedChannels); |
| 155 | 159 | |
| 156 | 160 | assignmentClient->start(QCoreApplication::applicationFilePath(), _childArguments); |
| 157 | − | |
| 158 | − // make sure we hear that this process has finished when it does | |
| 159 | − connect(assignmentClient, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(childProcessFinished())); | |
| 160 | − | |
| 161 | − qDebug() << "Spawned a child client with PID" << assignmentClient->pid(); | |
| 162 | − _childProcesses.insert(assignmentClient->processId(), assignmentClient); | |
| 161 | + | |
| 162 | + if (assignmentClient->processId() > 0) { | |
| 163 | + // make sure we hear that this process has finished when it does | |
| 164 | + connect(assignmentClient, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(childProcessFinished())); | |
| 165 | + | |
| 166 | + qDebug() << "Spawned a child client with PID" << assignmentClient->processId(); | |
| 167 | + _childProcesses.insert(assignmentClient->processId(), assignmentClient); | |
| 168 | + } | |
| 163 | 169 | } |
| 164 | 170 | |
| 165 | 171 | void AssignmentClientMonitor::checkSpares() { |