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

Offen
#359 9 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@luite arbeitet bereits daran.

Seit 05.12.2026.

  • #397 von @alt-romes — offen

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
50/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Ruhig
Tech-Stack
haskell

Rechercherichtung

Beginne damit, die Implementierungen von getProcessExitCode und waitForProcess zu finden, und führe anschließend das angehängte Beispiel NonChildProcessHandleDemo.txt aus, um das Verhalten zu reproduzieren. Vergleiche die Behandlung eines Prozesses, der kein Kindprozess ist, mit der ECHILD-Semantik von wait(2); abgeschlossen ist die Aufgabe, wenn beide Funktionen für diesen Fall nicht mehr ExitSuccess melden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
Haskell
Sterne
91
Forks
93
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus haskell/process

Alle Issues in haskell/process

Ähnliche Issues

Weitere Issues zu Haskell

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.