diff --git a/Userland/Libraries/LibCore/LocalServer.cpp b/Userland/Libraries/LibCore/LocalServer.cpp index 70da25e06dc..543ee3bf30b 100644 --- a/Userland/Libraries/LibCore/LocalServer.cpp +++ b/Userland/Libraries/LibCore/LocalServer.cpp @@ -47,6 +47,17 @@ ErrorOr LocalServer::take_over_from_system_server(ByteString const& socket return {}; } +ErrorOr LocalServer::take_over_fd(int socket_fd) +{ + if (m_listening) + return Error::from_string_literal("Core::LocalServer: Can't perform socket takeover when already listening"); + + m_fd = socket_fd; + m_listening = true; + setup_notifier(); + return {}; +} + void LocalServer::setup_notifier() { m_notifier = Notifier::construct(m_fd, Notifier::Type::Read, this); diff --git a/Userland/Libraries/LibCore/LocalServer.h b/Userland/Libraries/LibCore/LocalServer.h index cdccfcb6eb4..f5fc31b5cec 100644 --- a/Userland/Libraries/LibCore/LocalServer.h +++ b/Userland/Libraries/LibCore/LocalServer.h @@ -17,6 +17,7 @@ public: virtual ~LocalServer() override; ErrorOr take_over_from_system_server(ByteString const& path = ByteString()); + ErrorOr take_over_fd(int socket_fd); bool is_listening() const { return m_listening; } bool listen(ByteString const& address);