git: 2ca25d708908 - main - x11/konsole: avoid weird message when exiting last shell

From: Adriaan de Groot <adridg_at_FreeBSD.org>
Date: Mon, 18 Oct 2021 22:03:59 UTC
The branch main has been updated by adridg:

URL: https://cgit.FreeBSD.org/ports/commit/?id=2ca25d7089085af7f8a9201beba4d10ff4cdf1da

commit 2ca25d7089085af7f8a9201beba4d10ff4cdf1da
Author:     Adriaan de Groot <adridg@FreeBSD.org>
AuthorDate: 2021-10-18 21:52:49 +0000
Commit:     Adriaan de Groot <adridg@FreeBSD.org>
CommitDate: 2021-10-18 21:52:49 +0000

    x11/konsole: avoid weird message when exiting last shell
    
    Konsole complains about "kernel" still running in the terminal
    when exiting the last shell in the last tab; this only shows
    up if PID 0 is visible (depends on hardening options).
    Avoid that (on Linux, apparently the invalid PID equals the
    invalid foreground group ID).
    
    PR:             258996
    Reported by:    alt2600@icloud.com
---
 x11/konsole/Makefile                       |  1 +
 x11/konsole/files/patch-src_MainWindow.cpp | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/x11/konsole/Makefile b/x11/konsole/Makefile
index 5c4bc371e777..ade7a068cd68 100644
--- a/x11/konsole/Makefile
+++ b/x11/konsole/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	konsole
 DISTVERSION=	${KDE_APPLICATIONS_VERSION}
+PORTREVISION=	1
 CATEGORIES=	x11 kde kde-applications # kde kde-applications-applications
 
 MAINTAINER=	kde@FreeBSD.org
diff --git a/x11/konsole/files/patch-src_MainWindow.cpp b/x11/konsole/files/patch-src_MainWindow.cpp
new file mode 100644
index 000000000000..57f3f4d6d33a
--- /dev/null
+++ b/x11/konsole/files/patch-src_MainWindow.cpp
@@ -0,0 +1,25 @@
+From 00d565eedea5be0b5c9ad66b29bdf14c63a5e035 Mon Sep 17 00:00:00 2001
+From: Adriaan de Groot <groot@kde.org>
+Date: Mon, 18 Oct 2021 11:07:30 +0200
+Subject: [PATCH 2/2] Special-case PID 0 on FreeBSD
+
+PID 0 is the kernel; when the shell exits, the process ID for
+the session becomes 0. Downstream bug report
+	https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258996
+--- src/MainWindow.cpp.orig	2021-10-04 22:10:38 UTC
++++ src/MainWindow.cpp
+@@ -609,6 +609,14 @@ bool MainWindow::queryClose()
+             continue;
+         }
+ 
++        // On FreeBSD, after exiting the shell, the foreground GID is
++        // an invalid value, and the shell PID is 0. Those are not equal,
++        // so isForegroundProcessActive() returns true -- leading to a
++        // complaint about "kernel" here. Special-case PID 0 to avoid that.
++        if (session->processId() == 0) {
++            continue;
++        }
++
+         const QString defaultProc = session->program().split(QLatin1Char('/')).last();
+         const QString currentProc = session->foregroundProcessName().split(QLatin1Char('/')).last();
+