Skip to content

Commit a1d85ce

Browse files
committed
fix: stop app.slice before logout/shutdown to ensure clean user process termination
Send SIGKILL to all processes in app.slice via systemd D-Bus KillUnit before logout and shutdown. Pms: BUG-350165,BUG-350171 Change-Id: Ibba4a31d93f107946af86b4b1e06a96a5ab4d0eb
1 parent c3fb674 commit a1d85ce

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

src/dde-session/impl/sessionmanager.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ void SessionManager::prepareLogout(bool force)
174174
stopRedshift();
175175
stopObexService();
176176
stopDock();
177+
stopAppSlice();
177178

178179
// 防止注销时,蓝牙音频设置没有断开连接
179180
disconnectAudioDevices();
@@ -513,6 +514,7 @@ void SessionManager::prepareShutdown(bool force)
513514
{
514515
stopSogouIme();
515516
stopBAMFDaemon();
517+
stopAppSlice();
516518
preparePlayShutdownSound();
517519
stopPulseAudioService();
518520

@@ -689,6 +691,22 @@ void SessionManager::stopDock()
689691
VIEW_SERVICE(DDE_DOCK_SERVICE);
690692
}
691693

694+
bool SessionManager::killUnitProcesses(const QString &unit, int signal)
695+
{
696+
auto reply = m_systemd1ManagerInter->KillUnit(unit, "all", signal);
697+
if (reply.isError()) {
698+
qWarning() << "failed to kill unit:" << unit << ", error:" << reply.error().name();
699+
return false;
700+
}
701+
702+
return true;
703+
}
704+
705+
void SessionManager::stopAppSlice()
706+
{
707+
killUnitProcesses(APP_SLICE, SIGKILL);
708+
}
709+
692710
void SessionManager::disconnectAudioDevices()
693711
{
694712
auto msg = QDBusInterface("org.deepin.dde.Bluetooth1"

src/dde-session/impl/sessionmanager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ public Q_SLOTS:
9191
void stopBAMFDaemon();
9292
void stopRedshift();
9393
void stopDock();
94+
bool killUnitProcesses(const QString &unit, int signal);
95+
void stopAppSlice();
9496
void disconnectAudioDevices();
9597

9698
void preparePlayShutdownSound();

src/utils/utils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2021 - 2023 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2021 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

@@ -16,6 +16,7 @@
1616
#define BAMFDAEMON_SERVICE "bamfdaemon.service"
1717
#define REDSHIFT_SERVICE "redshift.service"
1818
#define DDE_DOCK_SERVICE "dde-dock.service"
19+
#define APP_SLICE "app.slice"
1920

2021
// sound
2122
#define SOUND_EFFECT_SCHEMA "com.deepin.dde.sound-effect"

0 commit comments

Comments
 (0)