MCP stdio: optional Linux PR_SET_PDEATHSIG so a server dies with its parent even on SIGKILL / panic=abort
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Start with the stdio spawn path that sets kill_on_drop(true) and own_process_group, and the StdioOptions builder, to see where a die_with_parent option would hook in. The design question is whether PR_SET_PDEATHSIG should fire on the forking thread's exit under Tokio, so read how tokio::process::Command::spawn forks before writing code. Tests belong in tests/mcp_stdio_test.rs, gated to Linux, covering the SIGKILL case, a control without the option, and the getppid guard. Done means the option works, non-Linux behaviour is decided and documented, and the tests pass.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Asked for by: yoyo-evolve (its #1100). An MCP stdio server should not outlive the host process.
What yoagent does today (0.26.6):
- Every stdio server is spawned with
kill_on_drop(true). StdioOptions::new().own_process_group(true)(0.25.16) puts the server in its own process group. That group is killed on close or drop, and since 0.26.0 also as soon as the command's own exit is seen (annpx→nodelauncher).- A panic that unwinds drops the
McpClient, so the server goes too.
The gap: when the parent dies without running destructors, nothing kills the server. That happens on SIGKILL, OOM-kill, panic = "abort", or std::process::exit without dropping the client. The server, and in a process group everything it started, keeps running, reparented to init.
Proposal: an opt-in, Linux-only StdioOptions::die_with_parent(true).
- In a
pre_exechook it callsprctl(PR_SET_PDEATHSIG, SIGKILL)(vialibc, already acfg(unix)dependency), then checksgetppid()against the parent's pid captured before the fork. If the parent is already gone, the child exits. This is the documented race guard. - It sits beside
own_process_group. The death signal reaches only the direct child (the launcher), so it pairs withown_process_group: the launcher dying is then seen by the existing group cleanup only if yoagent is still alive. Document that a server started through a launcher (npx) may leave grandchildren behind on a SIGKILLed parent, unless the launcher itself forwards the signal. - On non-Linux targets, return an error from the builder, or make it a documented no-op (decide which). macOS has no
PDEATHSIG; a kqueueNOTE_EXITwatcher in a helper process would be a separate, larger design. - Caveat to document:
PR_SET_PDEATHSIGfires when the thread that forked exits, not the process. Tokio spawns from a runtime worker thread, so a worker thread exiting (runtime shutdown with the client still alive) would kill the server early. Verify howtokio::process::Command::spawnforks, and whether this needs spawning from a long-lived thread, before choosing the default semantics.
Tests: Linux-only (#[cfg(target_os = "linux")]), in tests/mcp_stdio_test.rs style:
- Spawn a helper process that starts a bash-scripted server with the option set, record the server's pid,
SIGKILLthe helper, and assert the server is gone within a bound. - A control test without the option: the server survives, then clean it up.
- The
getppidrace guard.
Not in scope: changing the default. The option is opt-in, and hosts that already supervise their children (systemd, containers) don't need it.
- Ngôn ngữ chính
- Rust
- Star
- 327
- Fork
- 46
- Merge trung bình
- 2 giờ 36 phút
- Pull request đã merge (30 ngày)
- 107
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của yologdev/yoagent
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement P3
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement P3
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của yologdev/yoagent
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 5 ngày
-
bug studies ui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
userFRM/egui-charts#3308 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
marketing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
meerkat-lang/meerkat#279 ·
Maintainer thường phản hồi trong vòng 1 ngày