Fix checking of foreground process

The old method of checking it has unnecessary overhead (doing a full
process info update), and wasn't very reliable.

Instead just get the original shell PID from QProcess (via KProcess),
and the foreground process from the PTY.

CCBUG: 367746
REVIEW: 128789
(cherry picked from commit 79ca76a946)
wilder-portage
Martin T. H. Sandsmark 10 years ago committed by Kurt Hindenburg
parent 17cf652a9c
commit 17a3ee5dfa
  1. 3
      src/MainWindow.cpp
  2. 9
      src/Session.cpp

@ -536,8 +536,9 @@ bool MainWindow::queryClose()
QStringList processesRunning;
foreach(Session *session, _viewManager->sessions()) {
if (!session)
if (!session || !session->isForegroundProcessActive()) {
continue;
}
const QString defaultProc = session->program().split('/').last();
const QString currentProc = session->foregroundProcessName().split('/').last();

@ -823,9 +823,7 @@ bool Session::closeInNormalWay()
}
// Check if the default shell is running, in that case try sending an EOF for a clean exit
const QString defaultProc = program().split('/').last();
const QString currentProc = foregroundProcessName().split('/').last();
if (defaultProc == currentProc) {
if (!isForegroundProcessActive()) {
_shellProcess->sendEof();
if (_shellProcess->waitForFinished(1000)) {
@ -992,6 +990,9 @@ ProcessInfo* Session::getProcessInfo()
ProcessInfo* process = 0;
if (isForegroundProcessActive()) {
if (_foregroundProcessInfo == nullptr) {
updateForegroundProcessInfo();
}
process = _foregroundProcessInfo;
} else {
updateSessionProcessInfo();
@ -1469,7 +1470,7 @@ int Session::foregroundProcessId()
bool Session::isForegroundProcessActive()
{
// foreground process info is always updated after this
return updateForegroundProcessInfo() && (processId() != _foregroundPid);
return (_shellProcess->pid() != _shellProcess->foregroundProcessGroup());
}
QString Session::foregroundProcessName()

Loading…
Cancel
Save