Exit of the last `clone(CLONE_VM)` child ends the parent process
维护者通常 3 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- c, linux
调研方向
Start in src/runtime/forkipc.c at vm_clone_thread_run around line 1446 and read the proc_request_exit_group call and its comment. Compare the clone child’s exit handling with the Linux behavior described in the issue, including how the parent is woken and how waitpid receives the child status. Done means the parent remains alive to wait for the child and return its own exit code.
由索引模型根据 Issue 内容生成。
描述
When the last clone(CLONE_VM) child (without CLONE_THREAD) of an elfuse process exits, vm_clone_thread_run (src/runtime/forkipc.c:1446, at 173b23b) calls proc_request_exit_group with the child's exit code. The parent ends with it, even when the parent is still running and has more work to do.
On Linux the child is a separate process. Its exit raises SIGCHLD in the parent, waitpid returns its status, and the parent keeps running.
Reproduce (static aarch64 binary):
#define _GNU_SOURCE
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>
static volatile int go;
static int child(void *a) { (void) a; while (!go) usleep(1000); return 0; }
int main(void) {
char *stk = malloc(1 << 16);
pid_t c = clone(child, stk + (1 << 16), CLONE_VM | SIGCHLD, NULL);
go = 1;
int st;
pid_t w = waitpid(c, &st, 0);
dprintf(2, "waited %d st=%x\n", w, st);
return 3;
}
- Linux 6.18.57 (qemu reference VM): prints
waited <pid> st=0, exits 3. - elfuse at 173b23b: prints nothing after the clone and exits 0, the child's code.
The comment at the call says the exit_group is there so that a main thread blocked in futex_wait or its run loop wakes up. To match Linux, that main thread would need another way to wake, and the parent would need to exit only through its own exit or exit_group.
test-proc-limits works around this in #448 by running its VM-clone check in a fork child.
Checked, not affected: posix_spawn, which glibc implements with clone(CLONE_VM | CLONE_VFORK). A static glibc guest that spawns busybox true, waits for it and returns 3 prints spawn rc=0 waited <pid> st=0 and exits 3, under elfuse at 173b23b and on Linux 6.18.57 alike.
- 主要语言
- C
- 星标
- 275
- 派生
- 29
- 平均合并
- 2 天 8 小时
- 30 天内合并 PR
- 17
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
sysprog21/elfuse 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 86/100
维护者通常 3 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 3 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 3 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 3 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 55/100
维护者通常 3 天内回复
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
valkey-io/valkey#4979 · 1 个 reaction ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
colbymchenry/codegraph#2770 ·
维护者通常 1 天内回复
-
area/ysql kind/enhancement priority/medium status/awaiting-triage
难度 2/5 1-3 小时 新手友好度 73/100
yugabyte/yugabyte-db#35578 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
test_announce_and_connect_via_dns binds a fixed port that other tests' nodes can be handed可能已有人在做 @ksedgwic 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 83/100
ElementsProject/lightning#9642 ·
维护者通常 2 天内回复