zyfeier opened a new pull request, #21611:
URL: https://github.com/apache/nuttx/pull/21611
## Summary
* Why: Exit notifications were sent from nxtask_exithook() before
group_leave(), so a waitpid() caller could return while the child
still had its files open. The "last member" was also decided with
sq_is_singular() at that early point.
* What: sched/task exit path - SIGCHLD to the parent and the waitpid()
wakeup without SCHED_HAVE_PARENT.
* How: Two commits. The first makes group_leave() return whether the
leaving task was the last member (decided under tg_lock, together
with the removal), records the exit status where it was, and sends
SIGCHLD only after the files are closed, working from IDs captured
before the call; _exit() also blocks signals before
group_kill_children(), so a handler that calls exit() again cannot
skip the wait for the siblings. The second applies the same to the
waitpid() waiters of a group without SCHED_HAVE_PARENT, holding the
group across the wakeup because group_leave() may already have
released it.
## Impact
* Is new feature added? Is existing feature changed? YES - exit
notifications now happen after the group's files are closed.
* Impact on user (will user need to adapt to change)? NO
* Impact on build (will build process change)? NO
* Impact on hardware (will arch(s) / board(s) / driver(s) change)? NO
* Impact on documentation (is update required / provided)? NO
* Impact on security (any sort of implications)? NO
* Impact on compatibility (backward/forward/interoperability)? NO -
group_leave() gains a return value; existing callers ignore it.
## Testing
I confirm that changes are verified on local setup and works as intended:
* Build Host(s): Linux x86_64, GCC (host) and aarch64-none-elf-gcc
* Target(s): sim:ostest (with and without SCHED_HAVE_PARENT),
qemu-armv8a:nsh_smp
Testing logs (runtime, sim:ostest, 5 loops, first commit alone):
```
user_main: Exiting
ostest_main: Exiting with status 0
```
Testing logs (runtime, sim:ostest with SCHED_HAVE_PARENT disabled and
MM_KASAN enabled, both commits, exercises the waitpid() wakeup path):
```
user_main: Exiting
ostest_main: Exiting with status 0
```
Testing logs (runtime, qemu-armv8a:nsh_smp, 4 CPUs):
```
NuttShell (NSH) NuttX 13.1.0
nsh> uname -a
NuttX 13.1.0 6b31acc1cca arm64 qemu-armv8a
```
--
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]