casaroli commented on code in PR #3658:
URL: https://github.com/apache/nuttx-apps/pull/3658#discussion_r4392211190


##########
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:
   `DEV_NULL` is `default !DEFAULT_SMALL` and nothing selects it, so on 
`moxa:nsh` and `lm3s6432-s2e:nsh` this `open()` fails and telnetd now exits at 
start.
   
   Fix: add `select DEV_NULL` to `NETUTILS_TELNETD`.



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