mirror of
https://github.com/espressif/openthread.git
synced 2026-07-29 15:17:47 +00:00
[posix] some platforms don't support MSG_NOSIGNAL (#4996)
On platforms that have SO_NOSIGPIPE, use that to achieve the same result. On platforms that have neither, emit a compile-time warning -- you may still receive the signal on those systems.
This commit is contained in:
@@ -299,10 +299,27 @@ void platformUartProcess(const fd_set *aReadFdSet, const fd_set *aWriteFdSet, co
|
||||
{
|
||||
#if OPENTHREAD_POSIX_CONFIG_DAEMON_ENABLE
|
||||
// Don't die on SIGPIPE
|
||||
#if !defined(MSG_NOSIGNAL)
|
||||
// some platforms (mac OS, Solaris) don't have MSG_NOSIGNAL
|
||||
// SOME of those (mac OS, but NOT Solaris) support SO_NOSIGPIPE
|
||||
// if we have SO_NOSIGPIPE, then set it. otherwise, we're going
|
||||
// to simply ignore it.
|
||||
#if defined(SO_NOSIGPIPE)
|
||||
int err;
|
||||
int flag;
|
||||
|
||||
flag = 1;
|
||||
err = setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &flag, sizeof(flag));
|
||||
VerifyOrDie(err == 0, OT_EXIT_ERROR_ERRNO);
|
||||
#else
|
||||
#warning "no support for MSG_NOSIGNAL or SO_NOSIGPIPE"
|
||||
#endif
|
||||
#define MSG_NOSIGNAL 0
|
||||
#endif // !defined(MSG_NOSIGNAL)
|
||||
rval = send(fd, sWriteBuffer, sWriteLength, MSG_NOSIGNAL);
|
||||
#else
|
||||
rval = write(fd, sWriteBuffer, sWriteLength);
|
||||
#endif
|
||||
#endif // OPENTHREAD_POSIX_CONFIG_DAEMON_ENABLE
|
||||
|
||||
if (rval < 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user