From 3ecfde193ad03e278730cb538d7aba2177361ad7 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 20 Mar 2019 01:09:35 +0100 Subject: [PATCH] GEventLoop: Quit the event loop on EOF from the WindowServer. --- LibGUI/GEventLoop.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/LibGUI/GEventLoop.cpp b/LibGUI/GEventLoop.cpp index accf6fae59..e157968e23 100644 --- a/LibGUI/GEventLoop.cpp +++ b/LibGUI/GEventLoop.cpp @@ -399,6 +399,7 @@ void GEventLoop::process_unprocessed_messages() bool GEventLoop::drain_messages_from_server() { + bool is_first_pass = true; for (;;) { WSAPI_ServerMessage message; ssize_t nread = read(s_event_fd, &message, sizeof(WSAPI_ServerMessage)); @@ -407,10 +408,17 @@ bool GEventLoop::drain_messages_from_server() quit(1); return false; } - if (nread == 0) + if (nread == 0) { + if (is_first_pass) { + fprintf(stderr, "EOF on WindowServer fd\n"); + quit(1); + return false; + } return true; + } assert(nread == sizeof(message)); m_unprocessed_messages.append(move(message)); + is_first_pass = false; } } @@ -482,6 +490,7 @@ bool GEventLoop::post_message_to_server(const WSAPI_ClientMessage& message) bool GEventLoop::wait_for_specific_event(WSAPI_ServerMessage::Type type, WSAPI_ServerMessage& event) { + for (;;) { fd_set rfds; FD_ZERO(&rfds);