getProcessExitCode/waitForProcess should throw ECHILD rather than return ExitSuccess for non-child process

未关闭
#359 9 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@luite 已经在做这个了。

开始于 2026年12月5日。

  • #397 来自 @alt-romes —— 未关闭

评估

难度
4/5
预计耗时
3-5 天
新手友好度
50/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
haskell

调研方向

首先定位 getProcessExitCode 和 waitForProcess 的实现,然后运行附带的 NonChildProcessHandleDemo.txt 示例以复现该行为。将非子进程的处理方式与 wait(2) 的 ECHILD 语义进行比较;当这两个函数对于该情况都不再报告 ExitSuccess 时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

https://www.man7.org/linux/man-pages/man2/wait.2.html

       ECHILD (for waitpid() or waitid()) The process specified by pid
              (waitpid()) or idtype and id (waitid()) does not exist or
              is not a child of the calling process.  (This can happen
              for one's own child if the action for SIGCHLD is set to
              SIG_IGN.  See also the Linux Notes section about threads.)

In https://github.com/well-typed/haskell-debugger, it took me a long while to uncover a bug that turned out to be caused by getProcessExitCode incorrectly returning Just ExitSuccess for a handle of a non-child process.

I'm "unsafely" (i.e with .Internals) constructing the handle from the PID of a process that was not spawned/is not a child of the process calling getProcessExitCode. It should throw something like ECHILD, following the manpage for wait.

I suspect waitForProcess should also fail with ECHILD here.

I've attached the AI generated counter example program I was using to observe the incorrect behavior outside of the much more complicated haskell-debugger

NonChildProcessHandleDemo.txt

主要语言
Haskell
星标
91
派生
93
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

haskell/process 的其他 Issue

查看 haskell/process 的全部 Issue

相似的 Issue

更多 Haskell Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。