This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit b75aab77d18e2eb5fc371351df844f6c0d3306a2
Author: Marco Casaroli <[email protected]>
AuthorDate: Mon Nov 2 11:17:04 2026 +0100

    netutils/dropbear: Do not die of SIGPIPE when a client closes.
    
    Upstream dropbear ignores SIGPIPE in svr-main.c, which the NuttX port
    replaces with dropbear_main.c.  So a write to a client that closed the
    connection raises SIGPIPE, and with CONFIG_SIG_SIGPIPE_ACTION the
    default action ends the server for all clients.
    
    Ignore SIGPIPE at the start, as upstream does.  The failed write then
    ends only the session.  The writes are in the upstream sources, so
    MSG_NOSIGNAL cannot be used.  task_spawn() starts the NSH sessions with
    the default action.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 netutils/dropbear/dropbear_main.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/netutils/dropbear/dropbear_main.c 
b/netutils/dropbear/dropbear_main.c
index 798ba2b55..28ae805fe 100644
--- a/netutils/dropbear/dropbear_main.c
+++ b/netutils/dropbear/dropbear_main.c
@@ -12,6 +12,7 @@
 
 #include <sys/socket.h>
 #include <setjmp.h>
+#include <signal.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -291,6 +292,12 @@ int main(int argc, FAR char *argv[])
       port = argv[1];
     }
 
+  /* As upstream svr-main.c: get EPIPE, not SIGPIPE, when a client closes.
+   * task_spawn() starts the NSH sessions with the default action.
+   */
+
+  signal(SIGPIPE, SIG_IGN);
+
   dropbear_setup(port);
 
   dropbear_wait_listen_sockets(listensocks, MAX_LISTEN_ADDR, &maxfd);

Reply via email to