nightt5879 opened a new pull request, #3511:
URL: https://github.com/apache/nuttx-apps/pull/3511

   ## Summary
   
   Fixes #2937.
   
   `system/popen` was embedding a copied `FILE` object in its private tracking 
container and copying it back in `pclose()`. That depends on libc `FILE` layout 
details.
   
   This PR makes `popen()` return the actual stream from `fdopen()` and keeps a 
small private `FILE * -> pid` tracking list so `pclose()` can find the spawned 
shell process without copying `FILE`.
   
   Scope:
   - Does not change supported `popen()` modes.
   - Does not change the spawn/file-action setup.
   - Keeps `pclose()` responsible for closing the stream and waiting for the 
shell pid.
   - Returns `EINVAL` if `pclose()` cannot find the stream in the private popen 
list.
   
   ## Impact
   
   `popen()`/`pclose()` no longer rely on libc `FILE` internals.
   
   - New feature: NO
   - User adaptation required: NO
   - Build process change: NO
   - Hardware/architecture/board change: NO
   - Documentation update required: NO
   - Security impact: NO
   - Compatibility impact: NO intended compatibility impact
   
   ## Testing
   
   Host:
   - Windows with WSL Ubuntu 24.04
   - Target: `sim:nsh`
   
   Checks:
   - `git diff --check`: pass
   - `checkpatch.sh -g HEAD~1..HEAD`: pass
   - `sim:nsh` build with `CONFIG_SYSTEM_POPEN=y` and 
`CONFIG_EXAMPLES_POPEN=y`: pass
     - confirmed `CC: popen.c`
     - result: `SIM elf with dynamic libs archive in nuttx.tgz`
   - `printf 'popen\npoweroff\n' | timeout 30s ./nuttx`: pass
     - confirmed `popen("help")` output is read
     - confirmed execution reaches `pclose()`


-- 
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]

Reply via email to