casaroli opened a new pull request, #3871: URL: https://github.com/apache/nuttx-apps/pull/3871
## Summary `pclose()` returned the result of `fclose()`. The close function of the stream waited for the command, but returned `OK` for any termination status, so `pclose()` returned 0 also when the command failed. Now the close function only closes the descriptor. `pclose()` keeps the process ID of the command, closes the stream, and returns the termination status from `dpclose()`, as POSIX requires. The first commit only fixes the old nxstyle errors in `popen.c` and `popen_test.c`. The last commit adds a test: `pclose()` of a command that exits with a failure must not return 0. The test runs with `CONFIG_SCHED_CHILD_STATUS` only, because only then is the status of a command that already exited kept. ## Impact `pclose()` returns the termination status of the shell (or of the command in the mode without a shell), instead of 0. ## Testing `testing/libc/popen` on `qemu-armv8a:knsh` (QEMU 11 with HVF on an Apple M4) with `CONFIG_PIPES`, `CONFIG_SCHED_CHILD_STATUS`, `CONFIG_SYSTEM_POPEN` and `CONFIG_TESTING_POPEN`: | | test 8 (`pclose()` of a failing command) | other tests | |---|---|---| | master + the new test | FAIL: `pclose()` returned 0 | 7 pass | | this PR | PASS (`0xff00`: NSH `sh -c` exits with 255) | 7 pass | `ostest` on `qemu-armv8a:knsh` and `qemu-armv8a:nsh` ends with `ostest_main: Exiting with status 0`. `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]
