Skip to content

Reject wait4 options that Linux refuses - #551

Open
xalestar wants to merge 1 commit into
sysprog21:mainfrom
xalestar:wait4-options
Open

xalestar wants to merge 1 commit into
sysprog21:mainfrom
xalestar:wait4-options

Conversation

@xalestar

@xalestar xalestar commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Intent: Make wait4 refuse the options that Linux refuses.

Failure fixed: wait4(pid, NULL, WEXITED) reaps the child on elfuse. Linux 6.18 returns EINVAL and leaves the child, because only waitid takes WEXITED. box64 makes this call after a vfork, so dash under box64 got ECHILD from its own wait and reported 255 as the status of each command.

This PR: sys_wait4 checks the option bits before it looks for a child, as kernel_wait4 does.

  • With the fix, elfuse and Linux 6.18 (QEMU) agree on all 32 single option bits with no child, on every bit but __WCLONE with an exited child, and on each valid bit paired with each unknown one.
  • test-process-lifecycle WAIT-07 passes as is (3/3), fails with the fix reverted (3/3), and passes on Linux.
  • dash under box64 0.4.3, child exits 5: status 255 before, 5 after.
  • make check passes. make test-matrix: elfuse-aarch64 338 passed, 0 failed; qemu-aarch64 312 passed, 0 failed. audit-known-limitations fails in the Rosetta lane, and on d3c0785 too.

Left out: __WCLONE reaps an exited fork child where Linux returns ECHILD, waitid accepts unknown options and none, and wait4(INT_MIN) returns ECHILD where Linux returns ESRCH.

Refs #246


Summary by cubic

Rejects wait4 option bits that Linux refuses, so calls like wait4(pid, NULL, WEXITED) now return EINVAL on elfuse and leave the child instead of reaping it. Previously sys_wait4 ignored unknown options and consumed the child, which made shells under box64 see ECHILD from their own wait and report status 255 for every command.

  • Adds WAIT-07 to test-process-lifecycle, verifying all 32 option bits match Linux behavior.
  • Known gaps left out: waitid has the same gap for unknown options, and wait4(INT_MIN) returns ECHILD where Linux returns ESRCH.

Written for commit 6df2ce7. Summary will update on new commits.

View guided diff

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread src/syscall/proc.c Resolved
sys_wait4 ignored option bits it did not know, so wait4(pid, NULL,
WEXITED) reaped the child. Linux fails that call with EINVAL, because
only waitid takes WEXITED, and leaves the child for a later wait.

box64 makes this call after a vfork, so a shell running under it got
ECHILD from its own wait and reported status 255 for every child it
started that way. Check the options first, as kernel_wait4 does.
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