casaroli opened a new pull request, #22583: URL: https://github.com/apache/nuttx/pull/22583
## Summary Add `W_EXITCODE(ret, sig)` and `W_STOPCODE(sig)` to `<sys/wait.h>`. They are not POSIX, but other systems have them, and programs use them to make the status value of a child that they ended themselves (for example the VTE terminal library). The values are the ones of the other systems: `W_EXITCODE(ret, sig)` is `(ret << 8) | sig` and `W_STOPCODE(sig)` is `(sig << 8) | 0x7f`. `W_EXITCODE(ret, 0)` and `W_STOPCODE(sig)` are the values that `waitpid()` gives for a child that exited with `ret` and for a child that `sig` stopped. `waitpid()` does not report a termination by a signal yet (`WIFSIGNALED()` is 0), so `W_EXITCODE()` with a non-zero `sig` has no NuttX status to compare with. A second commit describes the two macros in the `waitpid()` section of `Documentation/reference/user/03_task_control.rst`. ## Impact Two new macros in the `CONFIG_SCHED_WAITPID` part of `<sys/wait.h>`, next to the other status macros. No code changes. No in-tree code defines `W_EXITCODE` or `W_STOPCODE`, so nothing conflicts. The same in flat, protected and kernel builds. ## Testing The apps PR (`testing/sched/waitstop`, new case `w-exitcode`) compares the macros with the real `waitpid()` status of a child that exits with 5 and of a child that `SIGSTOP` stops. | Configuration | master 1af7ac541e4 | this PR | |---|---|---| | qemu-armv8a:nsh (flat, arm64, QEMU TCG) + `SIG_DEFAULT`, `TESTING_WAITSTOP` | 1 FAIL (`W_EXITCODE() or W_STOPCODE() is not defined`) | 31 PASS, 1 SKIP (no process groups) | | rv-virt:nsh64 (flat, riscv64, QEMU TCG), same options, waitstop twice in one boot | 1 FAIL each | 31 PASS, 1 SKIP each | Status values seen: exit 5 gives 0x500 = `W_EXITCODE(5, 0)`, SIGSTOP gives 0x137f = `W_STOPCODE(SIGSTOP)`. Builds with the CI image (`-Werror`): qemu-armv8a:nsh, qemu-armv8a:knsh, rv-virt:nsh64, rv-virt:pnsh64 (protected), rv-virt:knsh64 (kernel), qemu-intel64:nsh (x86_64): all OK. `tools/checkpatch.sh -c -u -m -g`: pass. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
