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

commit 8ed21e1fa557f3b62d829dd06004e6a518afdece
Author: Marco Casaroli <[email protected]>
AuthorDate: Tue Nov 3 12:01:03 2026 +0100

    fs/vfs: Raise SIGPIPE when sendfile() to a socket fails with EPIPE.
    
    sendfile() to a socket uses psock_sendfile(), which does not raise
    SIGPIPE.  The slow path (copyfile() through write()) raises it, so the
    same error gave SIGPIPE or not, depending on CONFIG_NET_SENDFILE and on
    the input file.  file_sendfile() now calls psock_sigpipe() for the
    result of psock_sendfile(), as sock_file_write() does for write().
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 fs/vfs/fs_sendfile.c    | 1 +
 include/nuttx/net/net.h | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/vfs/fs_sendfile.c b/fs/vfs/fs_sendfile.c
index 397d0341afd..9c3780eaa60 100644
--- a/fs/vfs/fs_sendfile.c
+++ b/fs/vfs/fs_sendfile.c
@@ -277,6 +277,7 @@ ssize_t file_sendfile(FAR struct file *outfile, FAR struct 
file *infile,
 
       if (ret >= 0 || ret != -ENOSYS)
         {
+          psock_sigpipe(psock, ret, 0);
           return ret;
         }
 
diff --git a/include/nuttx/net/net.h b/include/nuttx/net/net.h
index 2b3d3d1dd5e..cc4cd9d8619 100644
--- a/include/nuttx/net/net.h
+++ b/include/nuttx/net/net.h
@@ -886,8 +886,8 @@ ssize_t psock_sendmsg(FAR struct socket *psock, FAR const 
struct msghdr *msg,
  * Description:
  *   Raise SIGPIPE in the calling thread when a send on a stream socket
  *   failed with -EPIPE, unless 'flags' has MSG_NOSIGNAL.  The user
- *   interfaces (send(), sendto(), sendmsg() and write() on a socket) call
- *   it.  The psock_send*() interfaces do not raise SIGPIPE.
+ *   interfaces (send(), sendto(), sendmsg(), sendfile() and write() on a
+ *   socket) call it.  The psock_send*() interfaces do not raise SIGPIPE.
  *
  * Input Parameters:
  *   psock    The socket of the send

Reply via email to