From d8ec8174b8044689b76e33b13ed951adab169a74 Mon Sep 17 00:00:00 2001 From: Ian Craggs Date: Tue, 6 Jun 2023 16:43:38 +0100 Subject: [PATCH] Ignore SIGPIPE on Linux --- MQTTClient-C/src/linux/MQTTLinux.c | 3 ++- MQTTClient/src/linux/linux.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/MQTTClient-C/src/linux/MQTTLinux.c b/MQTTClient-C/src/linux/MQTTLinux.c index 7cd00845..d2c3c931 100644 --- a/MQTTClient-C/src/linux/MQTTLinux.c +++ b/MQTTClient-C/src/linux/MQTTLinux.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2017 IBM Corp. + * Copyright (c) 2014, 2023 IBM Corp. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -107,6 +107,7 @@ int linux_write(Network* n, unsigned char* buffer, int len, int timeout_ms) void NetworkInit(Network* n) { + signal(SIGPIPE, SIG_IGN); n->my_socket = 0; n->mqttread = linux_read; n->mqttwrite = linux_write; diff --git a/MQTTClient/src/linux/linux.cpp b/MQTTClient/src/linux/linux.cpp index 13231144..01ac9190 100644 --- a/MQTTClient/src/linux/linux.cpp +++ b/MQTTClient/src/linux/linux.cpp @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2017 IBM Corp. + * Copyright (c) 2014, 2023 IBM Corp. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -39,7 +39,7 @@ class IPStack public: IPStack() { - + signal(SIGPIPE, SIG_IGN); } int connect(const char* hostname, int port)