casaroli opened a new pull request, #3957:
URL: https://github.com/apache/nuttx-apps/pull/3957

   ## Summary
   
   rexecd copies data between the client socket and the socket pair that 
`dpopen()` gives for the command. When the command exits while the client still 
sends input, rexecd writes the input to the socket pair and gets `EPIPE`. Since 
apache/nuttx#21324, a send to a stream socket whose peer is gone also raises 
`SIGPIPE`. With `CONFIG_SIG_SIGPIPE_ACTION`, the default action of `SIGPIPE` 
ends rexecd, and the daemon stops for all clients.
   
   This PR uses `send()` with `MSG_NOSIGNAL` for both copies (to the client and 
to the command). The error ends only the session, as before. The process-wide 
`SIGPIPE` action is not changed, so a command started by rexecd keeps the 
default action.
   
   ## Impact
   
   Only netutils/rexecd. Without `CONFIG_SIG_SIGPIPE_ACTION` there is no 
change: a `SIGPIPE` without a handler is discarded, and the write already 
returned `EPIPE`. Both descriptors are always sockets (`dpopen()` with `O_RDWR` 
gives a local stream socket pair), so `send()` is equal to `write()` for them. 
No documentation change: Documentation/applications/netutils/rexecd does not 
describe this behaviour.
   
   ## Testing
   
   qemu-armv8a:nsh (flat build, QEMU with HVF) on nuttx master 1b0691e870d, 
with `CONFIG_NET`, `NET_TCP`, `NET_LOOPBACK`, `NET_LOCAL`, `NET_LOCAL_STREAM`, 
`SIG_DEFAULT`, `SIG_SIGPIPE_ACTION` and `NETUTILS_REXECD`. A test program 
`rexecsp.c` (builtin app) starts `rexecd -t` at priority 50, so that the 
command of a session runs to its end before rexecd copies data. Session 1 sends 
the command `echo hi` and the input `data\n` in one `send()` over 127.0.0.1. 
Then the test checks that rexecd still runs, and session 2 runs `echo second`.
   
   | Case | apps master 54374b3b2 | this PR |
   |---|---|---|
   | session 1 output | `hi` | `hi` |
   | rexecd still runs after session 1 | no, ended (wait status 0x100): FAIL | 
yes: PASS |
   | session 2 gives `second` | `connect()` fails with `ECONNREFUSED`: FAIL | 
PASS |
   
   ostest exits with status 0 in the same image, on master and with this PR.
   
   Build with `EXTRAFLAGS="-Wno-cpp -Werror"` and the options above, OK, no 
compiler warnings: qemu-armv8a:nsh (flat, arm64), rv-virt:nsh64 (flat, rv64), 
rv-virt:pnsh64 (protected, rv64). No defconfig enables rexecd.
   
   `tools/checkpatch.sh -c -u -m -g` passes.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to