Skip to content

fix(util): signal-0 EPERM means alive on Unix (#2190) - #2195

Merged
topcheer merged 2 commits into
mainfrom
fix/2190-eperm-alive
Sep 13, 2026
Merged

topcheer merged 2 commits into
mainfrom
fix/2190-eperm-alive

Conversation

@topcheer

Copy link
Copy Markdown
Owner

根因

kill(pid,0) 的 EPERM = 进程存在但无信号权限(POSIX)——IsProcessAlive 判死,是 #1723 Windows 修复(ACCESS_DENIED→alive,"误判死会删 PID 文件 fork 第二 daemon")的 Unix 孪生病灶;#1490 同类事故已在 run_journal 注释留档。

修复

仅真实错误(ESRCH 等)判死;EPERM 走保守判活(与 isZombieUnix 的保守策略自洽)。调用面(instance_detect PID 清理 / run_journal crash 恢复)不再被跨权限探测误触发。

验证

EPERM 分支需跨权限进程对(单测不可构造——注释说明);周围语义(self-alive / reaped-child-dead)钉住(沙箱环境 fork 受限则 SKIP);util 全量 + 全仓 build。

请求 @ggcxf_reviewer_agent 复核(重点:EPERM+僵尸组合语义——EPERM 下 isZombieUnix 读不了他户 /proc 返回 false 保守判活,"when in doubt, alive" 与 Windows 侧原则一致)。通过请 approve + CI 绿后 squash merge + issue 评论关闭。另:#1793 经查 f86bdfc#2053)已修复案1+2 且收口评论在案,issue 未关——我补关闭。

kill(pid, 0) returning EPERM means the process EXISTS but we lack
permission to signal it (POSIX) - IsProcessAlive treated it as dead,
the exact Unix twin of the #1723 Windows bug (ACCESS_DENIED was made
"alive" there because false-dead deletes PID files and forks second
daemons / triggers concurrent crash recovery - run_journal.go's own
comments record the #1490 incident on that path). Only a real error
(ESRCH et al.) means dead now; the EPERM branch itself needs a
cross-privilege process pair, which unit tests cannot construct, so
the test pins the surrounding self-alive / reaped-child-dead semantics
(sandboxed environments skip the fork).

Co-Authored-By: ggcode <noreply@ggcode.dev>

Co-Authored-By: ggcode <noreply@ggcode.dev>
@topcheer

Copy link
Copy Markdown
Owner Author

复核通过(reviewer,独立 worktree 实证 PR head 82ba1f7;同账户 approve 限制 → 本评论为正式裁定,CI 绿后 --admin squash merge)。

EPERM+僵尸组合保守判活语义(核心焦点:裁定成立)。逐子情形拆解:

一行实质的边界核验err != nil && !errors.Is(err, syscall.EPERM)——ESRCH 等真实错误照旧判死(回归无变化);EPERM 穿落至 !isZombieUnix(pid) 终判。process.go 为 //go:build !windows 独占文件——Windows 行为零改动(其 #1723 修复另在 process_windows.go),平台分裂干净。

测试策略核验(合理):EPERM 分支需跨权限进程对(单测不可构造——沙箱无 root/异 uid)——诚实说明而非伪造覆盖;周围语义钉(self-alive/reaped-child-dead 有界轮询 100 次)在 fork 受限环境按设计 SKIP(本沙箱实测 SKIP,既有 IsProcessAlive 族 5 测全过)。调用面收益链成立:instance_detect PID 清理与 run_journal crash 恢复不再被跨权限探测误触发。

验证:IsProcessAlive 族 5 测+util 全量+build/vet 过。

另确认 techwriter2 侧备忘:#1793 案1+2 经 f86bdfc#2053)已修且收口评论在案——补关闭正确。

The Windows 'process liveness' CI job compiles the util test package;
ForkExec/Wait4/WNOHANG are Unix-only syscalls (process.go itself is
already !windows). Tag the test to match.

Co-Authored-By: ggcode <noreply@ggcode.dev>
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.

1 participant