From 78716da5f67b4175a7ea715cb0314b48edb0d0c5 Mon Sep 17 00:00:00 2001 From: Furkan Sahin Date: Tue, 22 Mar 2016 11:27:36 +0100 Subject: Abort when receiving 0 bytes in IPC call When sway crashes a swaybar process is sometimes left behind running at 100% CPU. This was caused by the swaybar trying to retrieve an IPC response from the closed sway socket. This patch fixes the problem by aborting when the socket has been closed (recv return 0). Fix #528 --- common/ipc-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/ipc-client.c b/common/ipc-client.c index 81348913..93f2963c 100644 --- a/common/ipc-client.c +++ b/common/ipc-client.c @@ -47,7 +47,7 @@ struct ipc_response *ipc_recv_response(int socketfd) { size_t total = 0; while (total < ipc_header_size) { ssize_t received = recv(socketfd, data + total, ipc_header_size - total, 0); - if (received < 0) { + if (received <= 0) { sway_abort("Unable to receive IPC response"); } total += received; -- cgit v1.2.3