You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "casaroli (via GitHub)" <gi...@apache.org> on 2026/10/20 12:11:27 UTC
[PR] sched/Kconfig: Retain the child exit status by default in kernel builds. [nuttx]
casaroli opened a new pull request, #20837:
URL: https://github.com/apache/nuttx/pull/20837
## Summary
POSIX requires that `waitpid()` returns the exit status of a child that exited before the parent waits for it. NuttX does this only with `CONFIG_SCHED_CHILD_STATUS`, which is off by default. Without it, `waitpid()` fails with `ECHILD` when the child exits first. In a kernel build this is a usual case: a program starts another program with `posix_spawn()`, or with `vfork()` and `exec()`, and the new program can exit before the parent calls `waitpid()`. After `vfork()`, a child that calls `_exit()` has always exited when the parent continues.
This PR makes `CONFIG_SCHED_CHILD_STATUS` default to `y` in `CONFIG_BUILD_KERNEL`, and removes the line that is now redundant from the four kernel defconfigs that set it (imx93-evk:knsh, imx93-evk:koptee, qemu-intel64:knsh_romfs, qemu-intel64:knsh_romfs_pci). The Kconfig help, the task control reference and the fork()/vfork() guide say this.
## Impact
- Kernel builds only. All 43 kernel defconfigs already select `CONFIG_SCHED_HAVE_PARENT`, and all of them now configure with `CONFIG_SCHED_CHILD_STATUS=y`. `make savedefconfig` gives the same defconfig for all of them, except three that differ already on master (a `CONFIG_HOST_*` line).
- `waitpid()`, `wait()` and `waitid()` return the status of a child that already exited, instead of `ECHILD`.
- Size: qemu-armv8a:knsh text +1584 bytes, bss +408 bytes (16 status entries that the kernel allocates at boot). rv-virt:knsh64 text +1042 bytes, bss +384 bytes.
- A parent that starts children and does not wait for them now keeps a small status entry in the kernel heap for each child, until it waits or exits. NSH did this for background commands and pipeline stages; the apps PR fixes it. A configuration that does not want this can set `# CONFIG_SCHED_CHILD_STATUS is not set`.
## Testing
qemu-armv8a:knsh and qemu-armv8a:nsh under HVF.
A test program checks `waitpid()` after `vfork()` + `exec()`, `vfork()` + `_exit()`, `posix_spawn()` and `fork()` + `exec()`. On knsh, master fails 3 of the 6 cases with `ECHILD`; this PR passes all of them:
```
vforkexec: vfork + exec: waitpid(6)=6 errno 0 exited 1 status 42 (want 42): PASS
vforkexec: vfork + exec ENOENT: waitpid(10)=10 errno 0 exited 1 status 127 (want 127): PASS
vforkexec: vfork + _exit(7): waitpid(11)=11 errno 0 exited 1 status 7 (want 7): PASS
vforkexec: PASS
```
ostest passes on knsh and nsh (`Exiting with status 0`). With the apps PR, the kernel heap of knsh stays flat after 1500 background commands and 200 pipelines in NSH; without it, it grows by one entry for each of them.
Every kernel defconfig configures with `make olddefconfig`. qemu-armv8a:knsh and rv-virt:knsh64 build.
`tools/checkpatch.sh -c -u -m -g` passes.
depends-on: [apache/nuttx-apps/pull/3889]
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] sched/Kconfig: Retain the child exit status by default in kernel builds. [nuttx]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20837:
URL: https://github.com/apache/nuttx/pull/20837#issuecomment-6331852467
<!-- nuttx-depends-on-bot run-39563346517 -->
### 🔗 Cross-repo PR dependencies
The read-only Build run reported the following dependent PR(s) and fetched head SHA(s):
- https://github.com/apache/nuttx-apps/pull/3889 @ 4f7696c77f
CI run: https://github.com/apache/nuttx/actions/runs/39563346517
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] sched/Kconfig: Retain the child exit status by default in kernel builds. [nuttx]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20837:
URL: https://github.com/apache/nuttx/pull/20837#issuecomment-6306559921
<!-- nuttx-depends-on-bot run-39477333768 -->
### 🔗 Cross-repo PR dependencies
The read-only Build run reported the following dependent PR(s) and fetched head SHA(s):
- https://github.com/apache/nuttx-apps/pull/3889 @ 4f7696c77f
CI run: https://github.com/apache/nuttx/actions/runs/39477333768
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] sched/Kconfig: Retain the child exit status by default in kernel builds. [nuttx]
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #20837:
URL: https://github.com/apache/nuttx/pull/20837#discussion_r4328017418
##########
sched/Kconfig:
##########
@@ -707,7 +707,7 @@ config SCHED_HAVE_PARENT
config SCHED_CHILD_STATUS
bool "Retain child exit status"
- default n
+ default y if BUILD_KERNEL
Review Comment:
default BUILD_KERNEL
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] sched/Kconfig: Retain the child exit status by default in kernel builds. [nuttx]
Posted by "casaroli (via GitHub)" <gi...@apache.org>.
casaroli commented on code in PR #20837:
URL: https://github.com/apache/nuttx/pull/20837#discussion_r4329027469
##########
sched/Kconfig:
##########
@@ -707,7 +707,7 @@ config SCHED_HAVE_PARENT
config SCHED_CHILD_STATUS
bool "Retain child exit status"
- default n
+ default y if BUILD_KERNEL
Review Comment:
Done.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] sched/Kconfig: Retain the child exit status by default in kernel builds. [nuttx]
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #20837:
URL: https://github.com/apache/nuttx/pull/20837
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] sched/Kconfig: Retain the child exit status by default in kernel builds. [nuttx]
Posted by "casaroli (via GitHub)" <gi...@apache.org>.
casaroli closed pull request #20837: sched/Kconfig: Retain the child exit status by default in kernel builds.
URL: https://github.com/apache/nuttx/pull/20837
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] sched/Kconfig: Retain the child exit status by default in kernel builds. [nuttx]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20837:
URL: https://github.com/apache/nuttx/pull/20837#issuecomment-6305165770
<!-- membrowse-pr-comment -->
## <img src="https://membrowse.com/membrowse-logo.svg" height="24" align="top"> MemBrowse Memory Report · [Explore what changed →](https://membrowse.com/public/apache/nuttx?commit_sha=623d9f17c88ff93074f5e185a25a5b3b01247563)
### [qemu-armv8a](https://membrowse.com/public/apache/nuttx/target/qemu-armv8a/compare?head=623d9f17c88ff93074f5e185a25a5b3b01247563&base=1738e6fdf1c7a72ff27541f7c0018f4a903746f1)
- **Code**: .text.nsh_builtin -64 B, .text.nsh_parse_command +24 B (-0.0%, 351,524 B)
### [qemu-intel64](https://membrowse.com/public/apache/nuttx/target/qemu-intel64/compare?head=623d9f17c88ff93074f5e185a25a5b3b01247563&base=1738e6fdf1c7a72ff27541f7c0018f4a903746f1)
- **Code**: .text -68 B (-0.0%, 8,685,651 B)
*No memory changes detected for:*
- [arduino-mega2560](https://membrowse.com/public/apache/nuttx/target/arduino-mega2560/compare?head=623d9f17c88ff93074f5e185a25a5b3b01247563&base=1738e6fdf1c7a72ff27541f7c0018f4a903746f1)
- [esp32-devkitc](https://membrowse.com/public/apache/nuttx/target/esp32-devkitc/compare?head=623d9f17c88ff93074f5e185a25a5b3b01247563&base=1738e6fdf1c7a72ff27541f7c0018f4a903746f1)
- [hifive1-revb](https://membrowse.com/public/apache/nuttx/target/hifive1-revb/compare?head=623d9f17c88ff93074f5e185a25a5b3b01247563&base=1738e6fdf1c7a72ff27541f7c0018f4a903746f1)
- [mirtoo](https://membrowse.com/public/apache/nuttx/target/mirtoo/compare?head=623d9f17c88ff93074f5e185a25a5b3b01247563&base=1738e6fdf1c7a72ff27541f7c0018f4a903746f1)
- [rx65n-rsk2mb](https://membrowse.com/public/apache/nuttx/target/rx65n-rsk2mb/compare?head=623d9f17c88ff93074f5e185a25a5b3b01247563&base=1738e6fdf1c7a72ff27541f7c0018f4a903746f1)
- [s698pm-dkit](https://membrowse.com/public/apache/nuttx/target/s698pm-dkit/compare?head=623d9f17c88ff93074f5e185a25a5b3b01247563&base=1738e6fdf1c7a72ff27541f7c0018f4a903746f1)
- [stm32-nucleo-f103rb](https://membrowse.com/public/apache/nuttx/target/stm32-nucleo-f103rb/compare?head=623d9f17c88ff93074f5e185a25a5b3b01247563&base=1738e6fdf1c7a72ff27541f7c0018f4a903746f1)
---
<sub>Catch memory regressions in CI with [MemBrowse](https://membrowse.com). Free for open source.</sub>
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org