From 506707cc2bd3c64c1c09f6211141f1e226c15872 Mon Sep 17 00:00:00 2001 From: Dan Klishch Date: Thu, 1 Feb 2024 21:51:36 -0500 Subject: [PATCH] LibCore: Allow listening for socket errors and hang-ups --- Userland/Libraries/LibCore/Event.h | 2 ++ Userland/Libraries/LibCore/EventLoopImplementationUnix.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/Userland/Libraries/LibCore/Event.h b/Userland/Libraries/LibCore/Event.h index ecacfbe460d..11755f58bac 100644 --- a/Userland/Libraries/LibCore/Event.h +++ b/Userland/Libraries/LibCore/Event.h @@ -83,6 +83,8 @@ enum class NotificationType { None = 0, Read = 1, Write = 2, + HangUp = 4, + Error = 8, }; AK_ENUM_BITWISE_OPERATORS(NotificationType); diff --git a/Userland/Libraries/LibCore/EventLoopImplementationUnix.cpp b/Userland/Libraries/LibCore/EventLoopImplementationUnix.cpp index f6ff960989c..506501cf062 100644 --- a/Userland/Libraries/LibCore/EventLoopImplementationUnix.cpp +++ b/Userland/Libraries/LibCore/EventLoopImplementationUnix.cpp @@ -267,6 +267,10 @@ try_select_again: type |= NotificationType::Read; if (has_flag(revents, POLLOUT)) type |= NotificationType::Write; + if (has_flag(revents, POLLHUP)) + type |= NotificationType::HangUp; + if (has_flag(revents, POLLERR)) + type |= NotificationType::Error; type &= notifier.type(); if (type != NotificationType::None) ThreadEventQueue::current().post_event(notifier, make(notifier.fd(), type));