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 5d5ad414b43e747003cb79ed67ed92fae9de21e6 Author: Marco Casaroli <[email protected]> AuthorDate: Mon Nov 2 11:18:22 2026 +0100 examples/tcpecho: Do not die of SIGPIPE when a client closes. The echo server writes the data back with write(). When the client closed the connection, the write fails with EPIPE. A write to a stream socket whose peer is gone also raises SIGPIPE, and with CONFIG_SIG_SIGPIPE_ACTION the default action ends the server for all clients. Send with MSG_NOSIGNAL. The next read reports the closed connection and the server closes it, as before. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- examples/tcpecho/tcpecho_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/tcpecho/tcpecho_main.c b/examples/tcpecho/tcpecho_main.c index 2de49f6af..771d4d5b6 100644 --- a/examples/tcpecho/tcpecho_main.c +++ b/examples/tcpecho/tcpecho_main.c @@ -40,6 +40,7 @@ #include <net/if.h> #include <netinet/in.h> +#include <sys/socket.h> #include <arpa/inet.h> #include "netutils/netlib.h" @@ -336,7 +337,7 @@ static int tcpecho_server(void) } else { - write(sockfd, buf, n); + send(sockfd, buf, n, MSG_NOSIGNAL); } }
