From 3b158a61e9ceb8ee67bea9cd18cb0e5ef564b4cc Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Mon, 19 Nov 2018 09:47:08 -0800 Subject: [PATCH] [hdlc-interface] ignore errno EINTR in socket read (#3310) This commit changes `HdlcInterface::Read()` method to ignore `errno` `EINTR` (interrupt by a signal) during socket `read()`. It also uses `exit()` on error. --- src/posix/platform/hdlc_interface.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/posix/platform/hdlc_interface.cpp b/src/posix/platform/hdlc_interface.cpp index 92ece5758..8583065d0 100644 --- a/src/posix/platform/hdlc_interface.cpp +++ b/src/posix/platform/hdlc_interface.cpp @@ -141,20 +141,15 @@ void HdlcInterface::Read(void) rval = read(mSockFd, buffer, sizeof(buffer)); - if (rval < 0) - { - perror("HdlcInterface::Read()"); - - if (errno != EAGAIN) - { - abort(); - } - } - if (rval > 0) { Decode(buffer, static_cast(rval)); } + else if ((rval < 0) && (errno != EAGAIN) && (errno != EINTR)) + { + perror("HdlcInterface::Read()"); + exit(OT_EXIT_FAILURE); + } } void HdlcInterface::Decode(const uint8_t *aBuffer, uint16_t aLength)