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 987f72f26cc57995b5b5a889cd74bc3ceb0e05a5 Author: Marco Casaroli <[email protected]> AuthorDate: Mon Nov 2 11:14:14 2026 +0100 system/telnet: Do not stop telnet_chatd when a client closes. telnet_chatd sends to the users with send(). When a user closed the connection, a send to it fails with EPIPE. A send to a stream socket whose peer is gone also raises SIGPIPE, and with CONFIG_SIG_SIGPIPE_ACTION the default action ends the chat server for all users. Without the signal, _send() calls cleanup_exit() for each error other than EINTR and ECONNRESET, so EPIPE ends the server too. Send with MSG_NOSIGNAL, and handle EPIPE as ECONNRESET: stop sending to this user. The poll loop handles the closed connection, as it does after ECONNRESET. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- system/telnet/telnet_chatd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/telnet/telnet_chatd.c b/system/telnet/telnet_chatd.c index 5425f854c..d7bab4554 100644 --- a/system/telnet/telnet_chatd.c +++ b/system/telnet/telnet_chatd.c @@ -197,9 +197,9 @@ static void _send(int sock, const char *buffer, unsigned int size) while (size > 0) { - if ((ret = send(sock, buffer, size, 0)) == -1) + if ((ret = send(sock, buffer, size, MSG_NOSIGNAL)) == -1) { - if (errno != EINTR && errno != ECONNRESET) + if (errno != EINTR && errno != ECONNRESET && errno != EPIPE) { fprintf(stderr, "send() failed: %d\n", errno); cleanup_exit();
