1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 22:17:43 +00:00

SystemServer: Implement lazy spawning

For services explicitly configured as lazy, SystemServer will now listen
on the socket and only spawn the service once a client attempts to connect
to the socket.
This commit is contained in:
Sergey Bugaev 2019-11-26 19:41:16 +03:00 committed by Andreas Kling
parent ab98969403
commit 52b0bd06a8
4 changed files with 40 additions and 4 deletions

View file

@ -15,7 +15,7 @@ class Service final : public CObject {
C_OBJECT(Service)
public:
void spawn();
void activate();
void did_exit(int exit_code);
static Service* find_by_pid(pid_t);
@ -25,6 +25,8 @@ public:
private:
Service(const CConfigFile&, const StringView& name);
void spawn();
// Path to the executable. By default this is /bin/{m_name}.
String m_executable_path;
// Extra arguments, starting from argv[1], to pass when exec'ing.
@ -36,6 +38,8 @@ private:
bool m_keep_alive { false };
// Path to the socket to create and listen on on behalf of this service.
String m_socket_path;
// Whether we should only spawn this service once somebody connects to the socket.
bool m_lazy;
// The name of the user we should run this service as.
String m_user;
uid_t m_uid { 0 };
@ -45,7 +49,9 @@ private:
pid_t m_pid { -1 };
// An open fd to the socket.
int m_socket_fd { -1 };
RefPtr<CNotifier> m_socket_notifier;
void resolve_user();
void setup_socket();
void setup_notifier();
};