fix(process): 修复子进程退出时父进程唤醒逻辑#1516
Merged
fslongjin merged 1 commit intoDragonOS-Community:masterfrom Dec 20, 2025
Merged
Conversation
- 修正父进程唤醒条件,确保无论exit_signal为何值都唤醒父进程 - 修复线程组leader唤醒逻辑的位置错误 Signed-off-by: longjin <longjin@DragonOS.org>
Member
Author
|
@claude review this PR in Chinese |
|
Claude finished @fslongjin's task in 3m 5s —— View job 代码审查:fix(process): 修复子进程退出时父进程唤醒逻辑我已审查了PR #1516的修改,以下是我的分析: 修改概述本次修改修正了
技术分析原始问题:
Linux语义验证:
修复正确性: 潜在考虑
测试建议
改进建议(可选)
总结这是一个正确且必要的修复,解决了Linux wait语义实现中的缺陷。修改简洁明了,注释充分,符合项目编码规范。建议合并此PR。 修改详情@@ -409,24 +409,27 @@ impl ProcessManager {
e
);
}
- // 额外唤醒:父进程可能阻塞在 wait 系列调用上
- parent_pcb
- .wait_queue
- .wakeup_all(Some(ProcessState::Blocked(true)));
-
- // 根据 Linux wait 语义,线程组中的任何线程都可以等待同一线程组中任何线程创建的子进程。
- // 由于子进程被添加到线程组 leader 的 children 列表中,
- // 因此还需要唤醒线程组 leader 的 wait_queue(如果 leader 不是 parent_pcb 本身)。
- let parent_group_leader = {
- let ti = parent_pcb.thread.read_irqsave();
- ti.group_leader()
- };
- if let Some(leader) = parent_group_leader {
- if !Arc::ptr_eq(&leader, &parent_pcb) {
- leader
- .wait_queue
- .wakeup_all(Some(ProcessState::Blocked(true)));
- }
+ }
+
+ // 无论exit_signal是什么值,都要唤醒父进程的wait_queue
+ // 因为父进程可能使用__WALL选项等待任何类型的子进程(包括exit_signal=0的clone子进程)
+ // 根据Linux语义,exit_signal只决定发送什么信号,不决定是否唤醒父进程
+ parent_pcb
+ .wait_queue
+ .wakeup_all(Some(ProcessState::Blocked(true)));
+
+ // 根据 Linux wait 语义,线程组中的任何线程都可以等待同一线程组中任何线程创建的子进程。
+ // 由于子进程被添加到线程组 leader 的 children 列表中,
+ // 因此还需要唤醒线程组 leader 的 wait_queue(如果 leader 不是 parent_pcb 本身)。
+ let parent_group_leader = {
+ let ti = parent_pcb.thread.read_irqsave();
+ ti.group_leader()
+ };
+ if let Some(leader) = parent_group_leader {
+ if !Arc::ptr_eq(&leader, &parent_pcb) {
+ leader
+ .wait_queue
+ .wakeup_all(Some(ProcessState::Blocked(true)));
}
}
// todo: 这里还需要根据线程组的信息,决定信号的发送审查状态: ✅ 通过 <进度更新>
|
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.

解决wait_test里面
Waiters/WaitSpecificChildTest.WALL/0概率性的超时1min都没返回的问题