René's URL Explorer Experiment


Title: fix(git-host): macOS 上只剩未回收僵尸进程的进程组也能正常结束 by xiaoyumuxi · Pull Request #63 · Lithe-IDEA/Lithe-core-rust · GitHub

Open Graph Title: fix(git-host): macOS 上只剩未回收僵尸进程的进程组也能正常结束 by xiaoyumuxi · Pull Request #63 · Lithe-IDEA/Lithe-core-rust

X Title: fix(git-host): macOS 上只剩未回收僵尸进程的进程组也能正常结束 by xiaoyumuxi · Pull Request #63 · Lithe-IDEA/Lithe-core-rust

Description: 关联 Issue / Linked issue Closes 1lck/Lithe-IDEA#2017 PR 类型 / Type fix:缺陷修复 改动说明 / What changes 背景 / Why #2017:lithe-platform-tests 的 lsp_process::terminating_a_language_server_ends_the_processes_it_started 在 macOS 上不稳定。在 main 上连续运行 15 次,失败 8 次。报错是: a terminated server is disposed: CoreError { code: ProcessFailed, message: "Language-server process tree did not exit.", details: Some("Operation not permitted (os error 1)") } 原因在 git-host 的 Unix 进程组: ProcessTree::terminate 先调用 Group::kill,也就是 kill(-pgid, SIGKILL),再轮询进程组里是否还有进程。 Group::kill 只把 ESRCH(组里没有进程)当作正常,其他错误一律返回,terminate 随即失败,不再等待。 在 macOS 上,如果组里的进程都已经退出、但还没被父进程回收(都是僵尸进程),kill(-pgid, …) 返回 EPERM,不是 ESRCH。等它们被回收后,才返回 ESRCH。我用一个小程序在本机确认过:killpg 0 -> EPERM,killpg SIGKILL -> EPERM,回收后 -> ESRCH。 语言服务器的 dispose 在根进程被回收后调用 tree.terminate。这时根进程启动的 runtime 子进程也已经被杀掉,正在等新的父进程 launchd 回收。如果正好落在这个时间窗口里,就会出现上面的报错。 这不只是测试的问题。生产代码走的是同一条路径: lsp-engine 的 destroy 会把这个错误返回给调用方,会话留在注册表里不会删除。启动失败时的清理路径也一样。 关闭 SSH 远程会话时,tree.kill 和 tree.terminate 会误报失败,写出 remote.session.cleanup_failed 的 WARN 日志。 改动 / Changes rust/crates/git-host/src/lib.rs(Unix 的 Group) kill:EPERM 也返回 Ok。EPERM 表示组里没有一个进程接受这个信号:要么在 macOS 上都是还没回收的僵尸进程,要么属于其他用户。两种情况下都没有别的信号可以发。是否真的结束,交给 ProcessTree::terminate 在截止时间内等待判断;如果进程一直不消失,terminate 照常返回 TimedOut。 has_live_processes:行为不变,EPERM 仍然算作"还有进程",所以僵尸进程在被回收之前仍然算在组里。只改了注释:原来只写了"属于其他用户",补上 macOS 的僵尸进程。 rust/crates/platform-tests tests/platform/process_tree.rs:新增 #[cfg(unix)] 测试 a_unix_tree_of_exited_unreaped_processes_ends_without_error。 启动一个 Mode::Hold 夹具,用 tree.kill() 杀掉。 用 waitid(P_PID, …, WEXITED | WNOWAIT) 等到它退出,但不回收,确定它已经是僵尸进程。这一步在辅助线程里阻塞,主线程用 recv_timeout(DEADLINE) 等待,有明确的截止时间。 再调用一次 tree.kill(),断言返回 Ok。在 macOS 上,修复前这里返回 EPERM。 在后台线程回收根进程,断言 tree.terminate(DEADLINE) 返回 Ok,根进程是被信号结束的。 这个测试不依赖时间窗口:组里只剩僵尸进程的状态是确定构造出来的,不靠竞争条件。Linux 允许给僵尸进程发信号,所以这个测试在 Linux 上修复前后应当都通过(没有实测);所有 Unix 平台的预期相同,没有用 cfg! 区分。 Cargo.toml:加 [target.'cfg(unix)'.dev-dependencies] libc = "0.2",测试要调用 waitid。Cargo.lock 随之更新,没有引入新版本的 crate。 不在本 PR 范围内 / Out of scope Windows 用 Job 对象结束进程树,不走这段代码,不受影响。 #62(#2009 的修复)的验证说明里提到了这个不稳定的测试,那个 PR 没有改动这里的代码。 类型专属:fix 复现与根因 复现:在 main(6a14126)上反复运行 cargo test --manifest-path rust/Cargo.toml -p lithe-platform-tests,15 次中失败 8 次。 根因:见上方"背景"。Group::kill 的错误处理来自 git-host 引入 ProcessTree 的时候,没有考虑到 macOS 对只剩僵尸进程的进程组返回 EPERM。 影响平台:macOS。Linux 应当不受影响(没有实测):Linux 允许给僵尸进程发信号,kill 返回成功。Windows 不走这段代码。 检查项 已先写回归测试,确认它修复前失败、修复后通过。 测试路径:rust/crates/platform-tests/tests/platform/process_tree.rs 中的 a_unix_tree_of_exited_unreaped_processes_ends_without_error。 修复前:只撤回 git-host 的修改再运行,测试在第二次 tree.kill() 处失败: a tree whose processes all exited is killed again without error: Os { code: 1, kind: PermissionDenied, message: "Operation not permitted" } 修复后:通过。整个 lithe-platform-tests 连续运行 20 次,20 次全部通过,包括原来不稳定的 lsp_process::terminating_a_language_server_ends_the_processes_it_started。 [N/A] 手动复现:已经自动化。 已检查全部调用方:Group::kill 只通过 ProcessTree::kill 和 ProcessTree::terminate 调用。它们的调用方有: lsp-transport/process.rs 的 terminate_native 和 dispose; workspace/sessions.rs 的 SSH 会话清理和 reap。 这些调用方遇到 EPERM 时原来都会报失败或写 WARN,修复后都不再误报。进程真的没有结束时,terminate 仍然返回 TimedOut。 另一平台:Windows 不走这段代码。Windows 目标的 clippy 已通过。 只改了修复所需的代码。 [N/A] Agent Note:Core 仓库没有 .agents/notes/implemented/bug-fix/。这个约束写在 Group::kill 的注释和回归测试里。 范围检查 / Scope checks 功能矩阵:N/A,没有新增宿主能力。 插件归属:不涉及任何具体插件,测试只用 lithe-platform-fixture 夹具。 UI / i18n:N/A,没有界面文字。 统一日志系统:没有新增或改动日志事件。修复后,SSH 会话清理不再误写 remote.session.cleanup_failed。 逻辑归属:全部在 Rust Core。 性能与内存:没有新增进程、线程或缓存,也没有新增轮询;terminate 原有的轮询不变。 设置:N/A。 插件契约:N/A,没有改插件契约、能力版本、插件函数协议或宿主方法。 发行包与资源:N/A,没有新增运行时资源。 无用代码:没有。 验证 / Verification 本机为 Apple M4,Rust 1.100.0。 命令或操作 平台 结果 cargo fmt --manifest-path rust/Cargo.toml --all -- --check macOS arm64 通过 scripts/rust-core/verify-rust-core-comments.sh macOS arm64 通过 node scripts/rust-core/verify-platform-tests.mjs macOS arm64 通过 cargo test --manifest-path rust/Cargo.toml --workspace --features lithe-remote/server --no-fail-fast macOS arm64 通过:2106 passed,0 failed cargo test --manifest-path rust/Cargo.toml -p lithe-platform-tests,连续 20 次 macOS arm64 20 次全部通过(main 上 15 次失败 8 次) 撤回 git-host 的修改后运行新测试 macOS arm64 按预期失败,输出见上方 cargo clippy --manifest-path rust/Cargo.toml --workspace --all-targets -- -D warnings macOS arm64 通过 cargo clippy --manifest-path rust/Cargo.toml --workspace --all-targets --target x86_64-pc-windows-msvc -- -D warnings macOS 交叉检查 Windows 目标 通过 未能执行的检查和原因: 没有在 Linux 上运行新测试。按 Linux 内核的行为,它在修复前后都应通过;PR 的 Linux CI 会运行它。 没有在 Windows 上运行。Windows 不走这段代码,PR 标记 ready 后 CI 会运行 lithe-platform-tests。 提交前确认 / Final checks 分支从最新 main(6a14126)创建,目标分支 main。不依赖 #62。 以 Draft 提交,本地验证已通过。 没有无关改动、构建产物、凭据或个人路径。 本次验证没有启动 Lithe 应用,没有进程残留。

Open Graph Description: 关联 Issue / Linked issue Closes 1lck/Lithe-IDEA#2017 PR 类型 / Type fix:缺陷修复 改动说明 / What changes 背景 / Why #2017:lithe-platform-tests 的 lsp_process::terminating_a_language_server_ends_the_processe...

X Description: 关联 Issue / Linked issue Closes 1lck/Lithe-IDEA#2017 PR 类型 / Type fix:缺陷修复 改动说明 / What changes 背景 / Why #2017:lithe-platform-tests 的 lsp_process::terminating_a_language_server_ends_the_processe...

Opengraph URL: https://github.com/Lithe-IDEA/Lithe-core-rust/pull/63

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.113.4

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:83e35398-02e1-4fd6-99c0-63c77e02f223
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id8FD2:130575:6EFA6:8EFD4:6B076948
html-safe-nonce36d2ec38856f9e56fbb8d7ba999eacd01ca558053bd399aa1b94f58a839816c8
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RkQyOjEzMDU3NTo2RUZBNjo4RUZENDo2QjA3Njk0OCIsInZpc2l0b3JfaWQiOiI3Njc4ODE0NTc2ODEyOTc2NDU2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac38d30e9a9fd8f201fb314fe50f89f8260c9d5531147fe4c251e560263f94e5fc
hovercard-subject-tagpull_request:5333310875
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files
twitter:imagehttps://avatars.githubusercontent.com/u/145102356?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/145102356?s=400&v=4
og:image:alt关联 Issue / Linked issue Closes 1lck/Lithe-IDEA#2017 PR 类型 / Type fix:缺陷修复 改动说明 / What changes 背景 / Why #2017:lithe-platform-tests 的 lsp_process::terminating_a_language_server_ends_the_processe...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None59b8f5d72ef6b72449d99daafd74abe56273d30f4491cc421870d3c1bcc07535
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/Lithe-IDEA/Lithe-core-rust git https://github.com/Lithe-IDEA/Lithe-core-rust.git
octolytics-dimension-user_id340144206
octolytics-dimension-user_loginLithe-IDEA
octolytics-dimension-repository_id1449354685
octolytics-dimension-repository_nwoLithe-IDEA/Lithe-core-rust
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1449354685
octolytics-dimension-repository_network_root_nwoLithe-IDEA/Lithe-core-rust
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release2d876643548d19018f1accd48f914fec9bce9184
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FLithe-IDEA%2FLithe-core-rust%2Fpull%2F63%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FLithe-IDEA%2FLithe-core-rust%2Fpull%2F63%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=Lithe-IDEA%2FLithe-core-rust
Reloadhttps://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files
Reloadhttps://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files
Reloadhttps://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files
Lithe-IDEAhttps://github.com/Lithe-IDEA
Lithe-core-rusthttps://github.com/Lithe-IDEA/Lithe-core-rust
Codehttps://github.com/Lithe-IDEA/Lithe-core-rust
Issues1 (1)https://github.com/Lithe-IDEA/Lithe-core-rust/issues
Pull requests2 (2)https://github.com/Lithe-IDEA/Lithe-core-rust/pulls
Actionshttps://github.com/Lithe-IDEA/Lithe-core-rust/actions
Projectshttps://github.com/Lithe-IDEA/Lithe-core-rust/projects
Security and qualityhttps://github.com/Lithe-IDEA/Lithe-core-rust/security
Insightshttps://github.com/Lithe-IDEA/Lithe-core-rust/insights
Sign up for GitHub https://github.com/signup?return_to=%2FLithe-IDEA%2FLithe-core-rust%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FLithe-IDEA%2FLithe-core-rust%2Fissues%2Fnew%2Fchoose
xiaoyumuxihttps://github.com/xiaoyumuxi
mainhttps://github.com/Lithe-IDEA/Lithe-core-rust/tree/main
fix/2017-macos-zombie-process-grouphttps://github.com/Lithe-IDEA/Lithe-core-rust/tree/fix/2017-macos-zombie-process-group
Conversation 0 https://github.com/Lithe-IDEA/Lithe-core-rust/pull/63
Commits 1 https://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/commits
Checks 14 https://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/checks
Files changed https://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files
Please reload this pagehttps://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files
fix(git-host): macOS 上只剩未回收僵尸进程的进程组也能正常结束 https://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files#top
Show all changes 1 commit https://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files
746a2f0 fix(git-host): a process group of unreaped zombies ends without error… xiaoyumuxi Nov 16, 2026 https://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/commits/746a2f00902c00daa8eab865370a9cca6f41ae9a
Clear filters https://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files
Please reload this pagehttps://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files
Please reload this pagehttps://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files
Cargo.lock https://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files#diff-31311f589f85f3d98efe0429e90a39407857c13a4e81dd742f1ba22fab29950a
lib.rs https://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files#diff-3ef2b0c1022cdebf4f5e73459a1fcce79f06c2b3e39a11f942d53eaf04b745cd
Cargo.toml https://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files#diff-49da4904e360a7e344ec2c0cce20bd1ce6967a6b855c05395fef15b5a1c89c8d
process_tree.rs https://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files#diff-cf209923ce3d107b3eb7eb361118f206062b416020a6feac5a1643397ed26304
rust/Cargo.lockhttps://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files#diff-31311f589f85f3d98efe0429e90a39407857c13a4e81dd742f1ba22fab29950a
View file https://github.com/Lithe-IDEA/Lithe-core-rust/blob/746a2f00902c00daa8eab865370a9cca6f41ae9a/rust/Cargo.lock
Open in desktop https://desktop.github.com
how customized files appear on GitHubhttps://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github
Please reload this pagehttps://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files
rust/crates/git-host/src/lib.rshttps://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files#diff-3ef2b0c1022cdebf4f5e73459a1fcce79f06c2b3e39a11f942d53eaf04b745cd
View file https://github.com/Lithe-IDEA/Lithe-core-rust/blob/746a2f00902c00daa8eab865370a9cca6f41ae9a/rust/crates/git-host/src/lib.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/{{ revealButtonHref }}
https://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files#diff-3ef2b0c1022cdebf4f5e73459a1fcce79f06c2b3e39a11f942d53eaf04b745cd
https://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files#diff-3ef2b0c1022cdebf4f5e73459a1fcce79f06c2b3e39a11f942d53eaf04b745cd
https://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files#diff-3ef2b0c1022cdebf4f5e73459a1fcce79f06c2b3e39a11f942d53eaf04b745cd
rust/crates/platform-tests/Cargo.tomlhttps://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files#diff-49da4904e360a7e344ec2c0cce20bd1ce6967a6b855c05395fef15b5a1c89c8d
View file https://github.com/Lithe-IDEA/Lithe-core-rust/blob/746a2f00902c00daa8eab865370a9cca6f41ae9a/rust/crates/platform-tests/Cargo.toml
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/{{ revealButtonHref }}
https://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files#diff-49da4904e360a7e344ec2c0cce20bd1ce6967a6b855c05395fef15b5a1c89c8d
rust/crates/platform-tests/tests/platform/process_tree.rshttps://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files#diff-cf209923ce3d107b3eb7eb361118f206062b416020a6feac5a1643397ed26304
View file https://github.com/Lithe-IDEA/Lithe-core-rust/blob/746a2f00902c00daa8eab865370a9cca6f41ae9a/rust/crates/platform-tests/tests/platform/process_tree.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/{{ revealButtonHref }}
https://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files#diff-cf209923ce3d107b3eb7eb361118f206062b416020a6feac5a1643397ed26304
https://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files#diff-cf209923ce3d107b3eb7eb361118f206062b416020a6feac5a1643397ed26304
Please reload this pagehttps://github.com/Lithe-IDEA/Lithe-core-rust/pull/63/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlno-cache

Viewport: width=device-width


URLs of crawlers that visited me.