casaroli opened a new pull request, #20777: URL: https://github.com/apache/nuttx/pull/20777
## Summary `exec_swap()` gives the new image the pid of the caller and reverses the parent-child relationship: the caller becomes a child of the new image, and then exits. The new image got `SIGCHLD` and a child status for a process that it did not create. `wait()` in a program that a shell started with `fork()` and `exec()` returned that pid instead of failing with `ECHILD`, and the `SIGCHLD` interrupted its system calls. This PR gives the caller no parent and removes its child status from the new image. depends-on: apache/nuttx/pull/20492 ## Impact A program started with `fork()` + `exec()` no longer sees a child it did not create. Builds with `CONFIG_SCHED_HAVE_PARENT` only. The `depends-on` line is there because #20492 also changes `binfmt/binfmt_execmodule.c`; the two merge cleanly. ## Testing A test program on `qemu-armv8a:knsh` (QEMU 11 with HVF on an Apple M4): it calls `fork()`, the child calls `execl()` of the same program, and the new image calls `wait()`. The parent checks the exit status of the new image with `waitpid()`. | | master | this PR | |---|---|---| | `wait()` in the new image | `-1`, `EINTR` (the `SIGCHLD` of the exiting caller) | `-1`, `ECHILD` | | same, with `CONFIG_SCHED_CHILD_STATUS` | returns the pid of the caller | `-1`, `ECHILD` | | `waitpid()` in the parent | exit status 7 | exit status 7 | `ostest` on `qemu-armv8a:knsh` and `qemu-armv8a:nsh` stops at `roundrobin.c:281` on master and with this PR (a known timing failure under host load). `tools/checkpatch.sh -c -u -m -g` passes. -- 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]
