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/18 13:58:37 UTC
[PR] binfmt: Do not make the exec caller a child of the new image. [nuttx]
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] binfmt: Do not make the exec caller a child of the new image. [nuttx]
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #20777:
URL: https://github.com/apache/nuttx/pull/20777#discussion_r4308033774
##########
binfmt/binfmt_execmodule.c:
##########
@@ -86,6 +87,7 @@ static void exec_swap(FAR struct tcb_s *ptcb, FAR struct tcb_s *chtcb)
#ifdef CONFIG_SCHED_HAVE_PARENT
# ifdef CONFIG_SCHED_CHILD_STATUS
FAR struct child_status_s *tg_children;
Review Comment:
remove, let's reuse child
##########
binfmt/binfmt_execmodule.c:
##########
@@ -86,6 +87,7 @@ static void exec_swap(FAR struct tcb_s *ptcb, FAR struct tcb_s *chtcb)
#ifdef CONFIG_SCHED_HAVE_PARENT
# ifdef CONFIG_SCHED_CHILD_STATUS
FAR struct child_status_s *tg_children;
+ FAR struct child_status_s *child;
# else
uint16_t tg_nchildren;
Review Comment:
```suggestion
uint16_t nchildren;
```
--
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] binfmt: Do not make the exec caller a child of the new image. [nuttx]
Posted by "casaroli (via GitHub)" <gi...@apache.org>.
casaroli closed pull request #20777: binfmt: Do not make the exec caller a child of the new image.
URL: https://github.com/apache/nuttx/pull/20777
--
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] binfmt: Do not make the exec caller a child of the new image. [nuttx]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20777:
URL: https://github.com/apache/nuttx/pull/20777#issuecomment-6254139048
<!-- nuttx-depends-on-bot run-39158635665 -->
### ❌ Cross-repo dependency could not be applied
The Build report says the declared dependency PR(s) could not be applied, so CI did **not** run against the combined code:
- https://github.com/apache/nuttx/pull/20492
Reason: cherry-pick failed (if your PR has merge commits, rebase instead)
CI run: https://github.com/apache/nuttx/actions/runs/39158635665
--
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] binfmt: Do not make the exec caller a child of the new image. [nuttx]
Posted by "casaroli (via GitHub)" <gi...@apache.org>.
casaroli commented on code in PR #20777:
URL: https://github.com/apache/nuttx/pull/20777#discussion_r4308395280
##########
binfmt/binfmt_execmodule.c:
##########
@@ -86,6 +87,7 @@ static void exec_swap(FAR struct tcb_s *ptcb, FAR struct tcb_s *chtcb)
#ifdef CONFIG_SCHED_HAVE_PARENT
# ifdef CONFIG_SCHED_CHILD_STATUS
FAR struct child_status_s *tg_children;
Review Comment:
Done.
##########
binfmt/binfmt_execmodule.c:
##########
@@ -86,6 +87,7 @@ static void exec_swap(FAR struct tcb_s *ptcb, FAR struct tcb_s *chtcb)
#ifdef CONFIG_SCHED_HAVE_PARENT
# ifdef CONFIG_SCHED_CHILD_STATUS
FAR struct child_status_s *tg_children;
+ FAR struct child_status_s *child;
# else
uint16_t tg_nchildren;
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] binfmt: Do not make the exec caller a child of the new image. [nuttx]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20777:
URL: https://github.com/apache/nuttx/pull/20777#issuecomment-6250857553
<!-- membrowse-pr-comment -->
## <img src="https://membrowse.com/membrowse-logo.svg" height="24" align="top"> MemBrowse Memory Report
### [arduino-mega2560](https://membrowse.com/public/apache/nuttx/target/arduino-mega2560/compare?head=5cb1c25dde4c8ea0ce83d528385dc2abe427a5a9&base=6bdd71565ad4d0095b73f09ab81c4f570b2aeec5)
- **flash**: .data +16 B (+0.0%, 64,996 B / 262,144 B, total: 25% used)
- **sram**: .data +16 B (+0.6%, 2,734 B / 8,192 B, total: 33% used)
### [esp32-devkitc](https://membrowse.com/public/apache/nuttx/target/esp32-devkitc/compare?head=5cb1c25dde4c8ea0ce83d528385dc2abe427a5a9&base=6bdd71565ad4d0095b73f09ab81c4f570b2aeec5)
- **ROM**: .dram0.data +16 B, .flash.rodata +12 B (+0.0%, 126,308 B / 4,194,272 B, total: 3% used)
- **dram0_0_seg**: .dram0.data +16 B (+0.2%, 10,028 B / 180,736 B, total: 6% used)
- **drom0_0_seg**: .flash.rodata +12 B (+0.1%, 13,480 B / 4,194,272 B, total: 0% used)
### [hifive1-revb](https://membrowse.com/public/apache/nuttx/target/hifive1-revb/compare?head=5cb1c25dde4c8ea0ce83d528385dc2abe427a5a9&base=6bdd71565ad4d0095b73f09ab81c4f570b2aeec5)
- **flash**: .data +8 B, .text +12 B (+0.0%, 84,044 B / 4,194,304 B, total: 2% used)
- **sram**: .bss -16 B, .data +8 B (-0.2%, 3,956 B / 16,384 B, total: 24% used)
### [mirtoo](https://membrowse.com/public/apache/nuttx/target/mirtoo/compare?head=5cb1c25dde4c8ea0ce83d528385dc2abe427a5a9&base=6bdd71565ad4d0095b73f09ab81c4f570b2aeec5)
- **kseg0_progmem**: .data +4 B, .text +12 B (+0.0%, 67,184 B / 131,072 B, total: 51% used)
- **kseg1_datamem**: .data +4 B (+0.2%, 2,588 B / 32,256 B, total: 8% used)
### [qemu-armv8a](https://membrowse.com/public/apache/nuttx/target/qemu-armv8a/compare?head=5cb1c25dde4c8ea0ce83d528385dc2abe427a5a9&base=6bdd71565ad4d0095b73f09ab81c4f570b2aeec5)
- **Code**: .rodata +16 B, .text.exec_internal +4 B, .text.exec_module +28 B, .text.load_module +8 B (+0.0%, 349,568 B)
- **Data**: .data.g_version +2 B (+0.0%, 77,689 B)
### [qemu-intel64](https://membrowse.com/public/apache/nuttx/target/qemu-intel64/compare?head=5cb1c25dde4c8ea0ce83d528385dc2abe427a5a9&base=6bdd71565ad4d0095b73f09ab81c4f570b2aeec5)
- **Code**: .text +41 B (+0.0%, 8,684,228 B)
### [rx65n-rsk2mb](https://membrowse.com/public/apache/nuttx/target/rx65n-rsk2mb/compare?head=5cb1c25dde4c8ea0ce83d528385dc2abe427a5a9&base=6bdd71565ad4d0095b73f09ab81c4f570b2aeec5)
- **RAM**: .data +4 B (+0.1%, 6,590 B / 262,144 B, total: 3% used)
- **ROM**: .rodata +16 B (+0.0%, 87,732 B / 2,097,152 B, total: 4% used)
### [s698pm-dkit](https://membrowse.com/public/apache/nuttx/target/s698pm-dkit/compare?head=5cb1c25dde4c8ea0ce83d528385dc2abe427a5a9&base=6bdd71565ad4d0095b73f09ab81c4f570b2aeec5)
- **Code**: .text +752 B (+0.2%, 376,576 B)
- **Data**: .bss +32 B (+0.3%, 11,851 B)
### [stm32-nucleo-f103rb](https://membrowse.com/public/apache/nuttx/target/stm32-nucleo-f103rb/compare?head=5cb1c25dde4c8ea0ce83d528385dc2abe427a5a9&base=6bdd71565ad4d0095b73f09ab81c4f570b2aeec5)
- **flash**: .text +16 B (+0.0%, 34,480 B / 131,072 B, total: 26% used)
--
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] binfmt: Do not make the exec caller a child of the new image. [nuttx]
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis merged PR #20777:
URL: https://github.com/apache/nuttx/pull/20777
--
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] binfmt: Do not make the exec caller a child of the new image. [nuttx]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20777:
URL: https://github.com/apache/nuttx/pull/20777#issuecomment-6253794045
<!-- nuttx-depends-on-bot run-39133905516 -->
### 🔗 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/pull/20492 @ 9150d6042f
CI run: https://github.com/apache/nuttx/actions/runs/39133905516
--
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