Repository navigation
games/NXDoom, testing/ostest: Check WIFEXITED() before WEXITSTATUS(). - #3905
Merged
Merged
Conversation
Add a blank line after a declaration, and give an empty for loop braces, so that the next commit passes the style check. No functional change. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
The file selector takes the output of its child as the result only if WEXITSTATUS() of the child is 0. POSIX defines WEXITSTATUS() only when WIFEXITED() is true: for a child that a signal ended, the value is not an exit code, and it can be 0. Take the result only if the child exited and its exit status is 0. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
"exitting" is "exiting" in a printed message. No other change. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
The waitpid tests compared WEXITSTATUS() of each child with the expected exit code, without WIFEXITED(). POSIX defines WEXITSTATUS() only when WIFEXITED() is true, so a child that a signal ended would not be seen as an error if the value matched. Check WIFEXITED() first, and print the whole status on an error. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
acassis
approved these changes
Oct 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POSIX defines
WEXITSTATUS()only whenWIFEXITED()is true (wait()): "If the value of WIFEXITED(stat_val) is non-zero, this macro shall evaluate to the low-order 8 bits of the status argument that the child process passed to _exit() or exit(), or the value the child process returned from main()." For a child that a signal ended, the value ofWEXITSTATUS()is not an exit code, and it can be 0.Two places in nuttx-apps used
WEXITSTATUS()withoutWIFEXITED():games/NXDoom/textscreen/txt_fileselect.c: the file selector took the output of its child as the result whenWEXITSTATUS()was 0. It now takes it only if the child exited and its exit status is 0.testing/ostest/waitpid.c: three checks comparedWEXITSTATUS()with the expected exit code. They now checkWIFEXITED()first, and an error prints the whole status.The other users in nuttx-apps already check
WIFEXITED()first.Two small commits come first, so that the style check passes on the whole files: two older nxstyle errors in
txt_fileselect.c(a blank line, braces for an emptyforloop), and a spelling error in a message ofwaitpid.c.Impact
None for a child that exits normally. A child that a signal ends is no longer taken as a success by the NXDoom file selector or by the ostest waitpid checks.
Testing
ostest exits with status 0 on
qemu-armv8a:knshandqemu-armv8a:nsh(QEMU with HVF), with this PR. Onqemu-armv8a:nsh(withCONFIG_SCHED_WAITPIDandCONFIG_SCHED_CHILD_STATUS) the three changed waitpid checks run and pass (stat_loc=0e00, exit status 14).raspberrypi-4b:nxdoom(arm64) builds with this PR, sotxt_fileselect.ccompiles.tools/checkpatch.sh -c -u -m -gpasses.