From 12ac7d27300290ab8a6ae136d94833f3194f7fc0 Mon Sep 17 00:00:00 2001 From: Jiacheng Guo Date: Fri, 22 May 2020 07:52:51 +0800 Subject: [PATCH] [posix] tolerate SIGPIPE under daemon mode (#4994) Chances are that the ot-ctl client exits between read error check and write. This will lead to a SIGPIPE crash. We can ignore this signal and check the error code instead. --- src/posix/platform/uart.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/posix/platform/uart.cpp b/src/posix/platform/uart.cpp index 0abacd37c..0fd572759 100644 --- a/src/posix/platform/uart.cpp +++ b/src/posix/platform/uart.cpp @@ -297,7 +297,12 @@ void platformUartProcess(const fd_set *aReadFdSet, const fd_set *aWriteFdSet, co if ((sWriteLength > 0) && (FD_ISSET(fd, aWriteFdSet))) { +#if OPENTHREAD_POSIX_CONFIG_DAEMON_ENABLE + // Don't die on SIGPIPE + rval = send(fd, sWriteBuffer, sWriteLength, MSG_NOSIGNAL); +#else rval = write(fd, sWriteBuffer, sWriteLength); +#endif if (rval < 0) {