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
https://www.man7.org/linux/man-pages/man2/wait.2.html
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
getProcessExitCodeincorrectly returningJust ExitSuccessfor 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 likeECHILD, following the manpage forwait.I suspect
waitForProcessshould also fail withECHILDhere.I've attached the AI generated counter example program I was using to observe the incorrect behavior outside of the much more complicated
haskell-debuggerNonChildProcessHandleDemo.txt