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 摘要。