ricardgb commented on code in PR #3658:
URL: https://github.com/apache/nuttx-apps/pull/3658#discussion_r4393781164
##########
netutils/telnetd/telnetd_daemon.c:
##########
@@ -115,6 +116,31 @@ int telnetd_daemon(FAR const struct telnetd_config_s
*config)
}
#endif /* CONFIG_SCHED_HAVE_PARENT && CONFIG_ENABLE_ALL_SIGNALS */
+ /* If the daemon was started without standard streams (e.g. spawned by
+ * nsh_telnetstart() before a USB console exists), descriptors 0..2 are
+ * free and any descriptor created below -- the listen socket, an
+ * accepted socket or a session driver -- could be allocated in the
+ * standard-stream range, where the per-session dup2(0..2) would clobber
+ * it. Anchor any free slot in 0..2 to /dev/null first so that can
+ * never happen.
+ */
+
+ for (; ; )
+ {
+ nullfd = open("/dev/null", O_RDWR);
+ if (nullfd < 0)
+ {
+ nerr("ERROR: open(/dev/null) failed: %d\n", errno);
+ goto errout;
Review Comment:
Good catch, thanks. Added `select DEV_NULL` to `NETUTILS_TELNETD`, in the
commit that introduces the `/dev/null` dependency. `moxa:nsh` and
`lm3s6432-s2e:nsh` now resolve to `CONFIG_DEV_NULL=y`, and `lm3s6432-s2e:nsh`
builds with `-Werror` (I could not build `moxa` locally: its assembly needs a
toolchain I do not have). While rewriting, I also brought both commits to the
CONTRIBUTING ยง1.5 form (subjects end with `.`, `Assisted-by:
AGENT_NAME:MODEL_VERSION`). The C code is unchanged.
*Prepared with the assistance of an AI agent (Claude Code).*
--
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]