Skip to content

Commit 8221f8c

Browse files
committed
[websocket] Mask uncaught SIGPIPE signals since error handling is already done through return values
1 parent 823dfc3 commit 8221f8c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/websockets/libwebsockets/LibWebsocketClient.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ along with OpenOCPP. If not, see <http://www.gnu.org/licenses/>.
1818

1919
#include "LibWebsocketClient.h"
2020

21+
#include <csignal>
2122
#include <cstdint>
2223
#include <functional>
2324
#include <iostream>
@@ -234,6 +235,12 @@ void LibWebsocketClient::process()
234235
// Save this pointer for further callbacks
235236
client = this;
236237

238+
// Mask SIG_PIPE signal
239+
sigset_t set;
240+
sigemptyset(&set);
241+
sigaddset(&set, SIGPIPE);
242+
pthread_sigmask(SIG_BLOCK, &set, NULL);
243+
237244
// Event loop
238245
int ret = 0;
239246
while (!m_end && (ret >= 0))

src/websockets/libwebsockets/LibWebsocketServer.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ along with OpenOCPP. If not, see <http://www.gnu.org/licenses/>.
1818

1919
#include "LibWebsocketServer.h"
2020

21+
#include <csignal>
2122
#include <cstdint>
2223
#include <functional>
2324
#include <iostream>
@@ -222,6 +223,12 @@ void LibWebsocketServer::process()
222223
// Save this pointer for further callbacks
223224
server = this;
224225

226+
// Mask SIG_PIPE signal
227+
sigset_t set;
228+
sigemptyset(&set);
229+
sigaddset(&set, SIGPIPE);
230+
pthread_sigmask(SIG_BLOCK, &set, NULL);
231+
225232
// Event loop
226233
int ret = 0;
227234
while (!m_end && (ret >= 0))

0 commit comments

Comments
 (0)