Skip to content

[kernel] Fix sys_wait4 not returning -ECHILD immediately in certain cases#2653

Merged
ghaerr merged 1 commit intomasterfrom
wait4
Apr 26, 2026
Merged

[kernel] Fix sys_wait4 not returning -ECHILD immediately in certain cases#2653
ghaerr merged 1 commit intomasterfrom
wait4

Conversation

@ghaerr
Copy link
Copy Markdown
Owner

@ghaerr ghaerr commented Apr 26, 2026

Since it was recently found that the IBM PC ELKS v0.9.0 images contain the wrong binary for Nano-X, a version increment to v0.9.1 will have to be made soon and new images produced. Since another wait-oriented kernel reparenting bug was also fixed recently in #2639, I thought to include a few other important kernel fixes recently found by @Vutshi's exploration into AI tools.

This PR fixes the wait4 syscall issue found by @Vutshi's ChatGPT Plus and Claude kernel audit in #2646. The primary issue was that wait4 would wait rather than return -ECHILD when a process ID passed that was not a child of the calling process.

This fix includes my modified code from Claude's proposed fix, as it was much less messy than that proposed by ChatGPT Plus.

Claude also pointed out another issue which is that in the case of the parent only having stopped or zombie children which do not match the passed PID, an extra sleep/wakeup cycle is performed. This inefficiency will be handled at a later time, and there is no regression test yet built for it.

The regression tests used to verify correctness, provided by ChatGPT and Claude, are also add here in elkscmd/test/syscall/. These are not yet compiled and distributed on images, but will be after more regression tests are seen. Both tests initially showed failure and now show success.

@ghaerr ghaerr merged commit 09ca1d9 into master Apr 26, 2026
1 check passed
@ghaerr ghaerr deleted the wait4 branch April 26, 2026 18:37
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