fix: change killClient to use SIGKILL instead of xcb_kill_client_checked#1463
Merged
robertkill merged 1 commit intolinuxdeepin:masterfrom Mar 3, 2026
Merged
fix: change killClient to use SIGKILL instead of xcb_kill_client_checked#1463robertkill merged 1 commit intolinuxdeepin:masterfrom
robertkill merged 1 commit intolinuxdeepin:masterfrom
Conversation
There was a problem hiding this comment.
Sorry @robertkill, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
10f7c23 to
7251a99
Compare
BLumia
approved these changes
Mar 2, 2026
18202781743
approved these changes
Mar 2, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia, robertkill The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
1. Modified killClient function to directly terminate the process using SIGKILL signal 2. Removed X11 client message event construction for WM_DELETE_WINDOW protocol 3. Added window PID lookup and validation before sending kill signal 4. Added include for csignal header for kill() function support 5. Added error logging when unable to retrieve window PID The previous implementation used the X11 WM_DELETE_WINDOW protocol which relies on applications properly handling graceful shutdown requests. This approach was unreliable as some applications ignore or don't implement this protocol. The new implementation directly terminates the process using SIGKILL, ensuring the application is forcefully closed regardless of its cooperation with X11 window management protocols. This provides more reliable window closing functionality in the task manager. Log: Changed window closing behavior to force terminate unresponsive applications Influence: 1. Test closing various applications from task manager to ensure they terminate 2. Verify that unresponsive applications can be successfully closed 3. Test with applications that previously ignored WM_DELETE_WINDOW requests 4. Check system stability after force-closing multiple applications 5. Verify no orphaned processes remain after killClient is called 6. Test with applications that have multiple windows to ensure proper process termination fix: 修改 killClient 使用 SIGKILL 替代 WM_DELETE_WINDOW 1. 修改 killClient 函数,直接使用 SIGKILL 信号终止进程 2. 移除了用于 WM_DELETE_WINDOW 协议的 X11 客户端消息事件构造 3. 添加了窗口 PID 查找和验证,在发送终止信号前进行检查 4. 添加了 csignal 头文件包含以支持 kill() 函数 5. 添加了无法获取窗口 PID 时的错误日志记录 之前的实现使用了 X11 WM_DELETE_WINDOW 协议,这依赖于应用程序正确处理优雅 关闭请求。这种方法不可靠,因为有些应用程序会忽略或不实现此协议。新的实现 直接使用 SIGKILL 终止进程,确保无论应用程序是否配合 X11 窗口管理协议,都 能被强制关闭。这为任务管理器提供了更可靠的窗口关闭功能。 Log: 修改窗口关闭行为,强制终止无响应的应用程序 Influence: 1. 测试从任务管理器关闭各种应用程序,确保它们能正常终止 2. 验证无响应的应用程序可以被成功关闭 3. 测试之前忽略 WM_DELETE_WINDOW 请求的应用程序 4. 检查强制关闭多个应用程序后的系统稳定性 5. 验证调用 killClient 后没有残留的孤儿进程 6. 测试具有多个窗口的应用程序,确保进程被正确终止 PMS: BUG-342617
deepin pr auto review这段代码修改了 以下是对这段代码的详细审查和改进意见: 1. 语法与逻辑
2. 代码质量
3. 代码性能
4. 代码安全
5. 改进建议为了增强代码的健壮性和安全性,建议进行以下修改:
改进后的代码示例#include <cerrno> // 用于 errno
#include <cstring> // 用于 strerror
void X11Utils::killClient(const xcb_window_t &winid)
{
if (winid == XCB_WINDOW_NONE)
return;
pid_t pid = getWindowPid(winid);
// 尝试通过 PID 强杀
if (pid > 0) {
// 先检查进程是否存在以及是否有权限 (发送 0 信号)
if (::kill(pid, 0) == 0) {
// 进程存在且有权限,发送 SIGKILL
if (::kill(pid, SIGKILL) == 0) {
return; // 成功
} else {
// kill 失败,记录错误
qCWarning(x11UtilsLog()) << "Failed to kill process" << pid << ":" << strerror(errno);
// 继续尝试下面的回退方案
}
} else {
// kill(pid, 0) 失败,可能是进程不存在或无权限
qCWarning(x11UtilsLog()) << "Process check failed for pid" << pid << ":" << strerror(errno);
// 继续尝试下面的回退方案
}
} else {
qCWarning(x11UtilsLog()) << "Cannot get pid for window:" << winid;
}
// 回退方案:如果通过 PID 失败(例如无法获取 PID 或 kill 失败),
// 尝试使用 XCB 原生方式关闭连接,作为最后的手段。
qCInfo(x11UtilsLog()) << "Fallback to xcb_kill_client for window:" << winid;
xcb_kill_client(getXcbConnection(), winid);
}总结原代码修改实现了强制关闭窗口的功能,但过于激进且缺乏错误处理。改进后的代码增加了错误检查、日志记录以及回退机制,提高了代码的健壮性和可维护性,同时保留了原有的功能兼容性。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SIGKILL signal
protocol
The previous implementation used the X11 WM_DELETE_WINDOW protocol which
relies on applications properly handling graceful shutdown requests.
This approach was unreliable as some applications ignore or don't
implement this protocol. The new implementation directly terminates the
process using SIGKILL, ensuring the application is forcefully closed
regardless of its cooperation with X11 window management protocols. This
provides more reliable window closing functionality in the task manager.
Log: Changed window closing behavior to force terminate unresponsive
applications
Influence:
terminate
requests
process termination
fix: 修改 killClient 使用 SIGKILL 替代 WM_DELETE_WINDOW
之前的实现使用了 X11 WM_DELETE_WINDOW 协议,这依赖于应用程序正确处理优雅
关闭请求。这种方法不可靠,因为有些应用程序会忽略或不实现此协议。新的实现
直接使用 SIGKILL 终止进程,确保无论应用程序是否配合 X11 窗口管理协议,都
能被强制关闭。这为任务管理器提供了更可靠的窗口关闭功能。
Log: 修改窗口关闭行为,强制终止无响应的应用程序
Influence:
PMS: BUG-342617