Skip to content

Preserve each child's exit status when waiting - #197

Merged
holzschu merged 2 commits into
holzschu:masterfrom
demrom:fix/per-child-wait-status
Oct 22, 2026
Merged

holzschu merged 2 commits into
holzschu:masterfrom
demrom:fix/per-child-wait-status

Conversation

@demrom

@demrom demrom commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

When two children in one session return different exit codes, waiting for the second and then the first reports the second child's code twice. waitpid and ios_full_waitpid read the shared session status, so a completed child's result can be overwritten before its caller waits.

Store the exit code with the synthetic PID and read that slot when waiting. Normal command returns, ios_exit and commands that finish without starting a thread record their result before the PID is released. Commands that end without recording a result retain status 130, the code already used for cancellation before dispatch. The slot is reset when the existing allocator reuses the PID.

tests/child-wait-status.m starts a child that returns 7 and another that waits for it before calling ios_exit(23). The parent waits in reverse order. The same executable reports 23/23 and exits 1 against master, then reports 7/23 and exits 0 with this change. It also checks a missing command returns 127 and empty and NULL commands return 0. Both frameworks were built with Xcode 27.1, arm64 Release, Simulator SDK 27.1 and an iOS 15 deployment target; the patched build uses the command in tests/README.md. The root README's all-targets iPhoneOS build also passes after resolving the declared Swift package dependencies and setting IPHONEOS_DEPLOYMENT_TARGET=15.0 for Xcode 27.

On an iPhone running iOS 27.0.1, the fixture run as an a-Shell command reports 7/23, missing 127 and empty/NULL 0. File copying, pipelines and exit code checks pass, and an ordinary command after the test writes the expected file.

@demrom
demrom marked this pull request as ready for review October 22, 2026 17:06
@holzschu
holzschu merged commit df998e7 into holzschu:master Oct 22, 2026
2 checks passed
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.

2 participants