summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-08-28 12:41:42 (GMT)
committerMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-08-28 17:12:36 (GMT)
commit79ca76a94696eda408927b122b0b531676d4ba93 (patch)
tree4936abba9d5e0f015ad8dfdd96cb6bac4aecea24
parente7770aba9f6af26cba3dbecc1ac085acb214c6cc (diff)
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
-rw-r--r--src/MainWindow.cpp3
-rw-r--r--src/Session.cpp9
2 files changed, 7 insertions, 5 deletions
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 6f56014..803eeaf 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 54d1034..9178eb2 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();
@@ -1507,7 +1508,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()