/** * @file IPC.cpp * @author apio (cloudapio.eu) * @brief Inter-process communication primitives. * * @copyright Copyright (c) 2023, the Luna authors. * */ #include namespace os::IPC { Result check_for_messages(os::LocalClient& client, decltype(handle_ipc_client_event) handler) { u8 id; auto rc = client.recv_typed(id); if (rc.has_error()) { if (rc.error() == EAGAIN) return {}; // No messages, and the caller does not want us to block. if (rc.error() == EINTR) return {}; // Let the caller check for anything having happened because a signal handler ran. return rc.release_error(); } return handler(client, id); } Result check_for_messages(os::LocalServer::Client& client, decltype(handle_ipc_server_event) handler) { u8 id; auto rc = client.recv_typed(id); if (rc.has_error()) { if (rc.error() == EAGAIN) return {}; // No messages, and the caller does not want us to block. if (rc.error() == EINTR) return {}; // Let the caller check for anything having happened because a signal handler ran. return rc.release_error(); } return handler(client, id); } }