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
The following commit(s) were added to refs/heads/master by this push:
new 34ae3eb78 netutils/rexecd: Do not die of SIGPIPE when a peer closes.
34ae3eb78 is described below
commit 34ae3eb78eaf1283c3b69b698135ad340b478d01
Author: Marco Casaroli <[email protected]>
AuthorDate: Mon Nov 2 08:42:18 2026 +0100
netutils/rexecd: Do not die of SIGPIPE when a peer closes.
rexecd copies data between the client socket and the socket pair of
dpopen(). When the command exits while the client still sends input,
the write to the socket pair fails with EPIPE. A send to a stream
socket whose peer is gone raises SIGPIPE, and with
CONFIG_SIG_SIGPIPE_ACTION the default action ends rexecd: the daemon
stops for all clients.
Use send() with MSG_NOSIGNAL for both copies. The error ends only the
session, as before. The command keeps the default SIGPIPE action.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <[email protected]>
---
netutils/rexecd/rexecd.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/netutils/rexecd/rexecd.c b/netutils/rexecd/rexecd.c
index 2ae489b6d..bbf149a55 100644
--- a/netutils/rexecd/rexecd.c
+++ b/netutils/rexecd/rexecd.c
@@ -128,7 +128,9 @@ static FAR void *doit(pthread_addr_t pvarg)
break;
}
- ret = write(sock, buf, ret);
+ /* MSG_NOSIGNAL: a closed peer ends this session, not rexecd */
+
+ ret = send(sock, buf, ret, MSG_NOSIGNAL);
if (ret < 0)
{
break;
@@ -143,7 +145,7 @@ static FAR void *doit(pthread_addr_t pvarg)
break;
}
- ret = write(fds[0].fd, buf, ret);
+ ret = send(fds[0].fd, buf, ret, MSG_NOSIGNAL);
if (ret < 0)
{
break;