Skip to content

任务管理器使用 pidfd,防止 PID 复用时结束错误进程 - #126

Merged
Leonmmcoset merged 1 commit into
mainfrom
feature/taskmgr-pidfd
Nov 25, 2026
Merged

Leonmmcoset merged 1 commit into
mainfrom
feature/taskmgr-pidfd

Conversation

@VasilyZa

Copy link
Copy Markdown
Collaborator

问题与效果

在任务管理器中打开“结束任务”确认框后,原进程可能先退出,系统也可能把同一个 PID 分配给新进程。现在确认操作始终绑定最初选中的进程。若它已经退出,界面会提示用户,新进程不会收到信号。

流程与实现

reliefos_task_snapshot_pidfds() 为快照中的每个进程返回一个独立的 FD_CLOEXEC 描述符。确认框保留选中行的描述符,用户确认后通过 pidfd_send_signal() 发送 SIGTERM。列表刷新和关闭确认框时会释放对应的描述符。此提交也更新了任务管理器翻译和运行时 API 文档。

验证

  • python3 -m unittest tools.test_procfs_taskmgr.ProcfsTaskmgrTests.test_status_snapshot_consumer 通过,覆盖描述符所有权、过期快照和旧内核行为。
  • 在单独导出的待提交内核源码上运行 make all test-header-export test-abi,内核构建成功,98 个导出头文件、70 个 ABI 记录和 27 个常量通过检查。
  • 在双核 QEMU/KVM 来宾中运行 tools/tests/pidfd_probe.c,7 项通过,退出状态为 0。覆盖 PID 复用、退出通知、信号权限、描述符继承和 waitid(P_PIDFD)。
  • 任务管理器已编译,已检查取消确认及目标提前退出时的界面行为。VMware 验证未完成。

兼容性与发布影响

保留原有 reliefos_task_snapshot() 接口。旧内核仍可显示进程列表,无法获得稳定描述符时会禁用对应目标的结束操作。kernel/reliefnt 更新到已推送至 ReliefNT main 的 b63f26ef。

Capture a close-on-exec pidfd with each available process snapshot entry and retain the selected handle through confirmation. Recheck the selected process through its descriptor so PID reuse cannot redirect a signal. Update the runtime API, catalogs, documentation and the ReliefNT gitlink together.
@Leonmmcoset
Leonmmcoset merged commit 1b902ab into main Nov 25, 2026
23 of 25 checks passed
@Leonmmcoset
Leonmmcoset deleted the feature/taskmgr-pidfd branch November 25, 2026 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants