Rexec rexecd dpopen#3558
Open
JianyuWang0623 wants to merge 2 commits into
Open
Conversation
When the relay loop exits early without entering any branch, ret would be returned uninitialized, tripping -Werror=maybe-uninitialized. Initialize it to 0. Assisted-by: GitHubCopilot:claude-4.8-opus Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
popen() now returns a fopencookie-backed FILE* whose fileno() yields the cookie pointer rather than a real descriptor, so poll() silently ignores the negative fd and the relay loop blocks forever waiting for command completion. See apache#3511 Use dpopen()/dpclose() to obtain the raw bidirectional socket descriptor directly, restoring the EOF/POLLHUP command-completion signal. Assisted-by: GitHubCopilot:claude-4.8-opus Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
xiaoxiang781216
approved these changes
Jun 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR contains two fixes for the
rexecd/rexecutilities undernetutils/.popen()now returns afopencookie()-backedFILE*. On such a streamfileno()returns the cookie pointer instead of a real file descriptor,which is typically negative.
rexecd's relay loop feeds that value intopoll(), where a negativefdis silently ignored, so the loop never seesthe child's
POLLIN/POLLHUP/EOF and blocks forever waiting for the commandto finish. (Related upstream change: system/popen: Avoid copying FILE #3511.)
Impact
rexecdno longer hangs after the remote command finishes; thecommand-completion (EOF/
POLLHUP) path works again. No API or CLI change.-Werror=maybe-uninitializedbuild break inrexec.c.rexecdnow depends ondpopen()/dpclose()(
CONFIG_SYSTEM_POPEN), the descriptor-based counterparts ofpopen()/pclose().Testing
Built with the standard nuttx-apps toolchain; warning-as-error build of
netutils/rexecandnetutils/rexecdpasses after theretinitialization fix.Runtime verified by running
rexecdon the target and issuing a remote commandfrom
rexec:rexec <host> <cmd>printed the command output but then hung; thesession never returned to the prompt because
poll()ignored the negativefileno()and the relay loop never observed command completion.rexec <host> <cmd>prints the output, receives EOF/POLLHUPwhen the child exits, and the session terminates cleanly.