diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 6f560144..803eeaf8 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.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(); diff --git a/src/Session.cpp b/src/Session.cpp index 14a0fbbf..ae539cdc 100644 --- a/src/Session.cpp +++ b/src/Session.cpp @@ -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()