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 2c8597eddf4466b5641f9ef9bbc1f60f3393effc
Author: Marco Casaroli <[email protected]>
AuthorDate: Mon Nov 2 11:19:22 2026 +0100

    examples/poll: Do not die of SIGPIPE when a client closes.
    
    net_listener and net_reader echo the data back with send().  When the
    client closed the connection, the send 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 example.
    
    Send with MSG_NOSIGNAL.  The send error closes only this connection, as
    before.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 examples/poll/net_listener.c | 2 +-
 examples/poll/net_reader.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/examples/poll/net_listener.c b/examples/poll/net_listener.c
index 2e04e3945..b9ebff6ef 100644
--- a/examples/poll/net_listener.c
+++ b/examples/poll/net_listener.c
@@ -144,7 +144,7 @@ static inline bool net_incomingdata(struct net_listener_s 
*nls, int sd)
 
           for (nbytes = ret, ptr = nls->buffer; nbytes > 0; )
             {
-              ret = send(sd, ptr, nbytes, 0);
+              ret = send(sd, ptr, nbytes, MSG_NOSIGNAL);
               if (ret < 0)
                 {
                   if (errno != EINTR)
diff --git a/examples/poll/net_reader.c b/examples/poll/net_reader.c
index cd02dabfb..d494f4774 100644
--- a/examples/poll/net_reader.c
+++ b/examples/poll/net_reader.c
@@ -187,7 +187,7 @@ static void net_receive(int sd)
 
               for (nbytes = ret, ptr = buffer; nbytes > 0; )
                 {
-                  ret = send(sd, ptr, nbytes, 0);
+                  ret = send(sd, ptr, nbytes, MSG_NOSIGNAL);
                   if (ret < 0)
                     {
                       if (errno != EINTR)

Reply via email to