wind: Spawn a new client process after startup
All checks were successful
continuous-integration/drone/pr Build is passing

Also, create the socket after dropping privileges.
This commit is contained in:
apio 2023-08-07 22:51:28 +02:00
parent cf341dd82f
commit e5bb07874d
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -6,6 +6,7 @@
#include <os/ArgumentParser.h> #include <os/ArgumentParser.h>
#include <os/File.h> #include <os/File.h>
#include <os/LocalServer.h> #include <os/LocalServer.h>
#include <os/Process.h>
#include <pwd.h> #include <pwd.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -45,9 +46,6 @@ Result<int> luna_main(int argc, char** argv)
auto screen = TRY(Screen::open()); auto screen = TRY(Screen::open());
auto server = TRY(os::LocalServer::create(socket_path, false));
TRY(server->listen(20));
Mouse mouse_pointer { screen.canvas() }; Mouse mouse_pointer { screen.canvas() };
ioctl(STDIN_FILENO, TTYSETGFX, 1); ioctl(STDIN_FILENO, TTYSETGFX, 1);
@ -73,6 +71,12 @@ Result<int> luna_main(int argc, char** argv)
} }
} }
auto server = TRY(os::LocalServer::create(socket_path, false));
TRY(server->listen(20));
StringView args[] = { "/usr/bin/gclient"_sv };
TRY(os::Process::spawn("/usr/bin/gclient"_sv, Slice<StringView> { args, 1 }, false));
ui::Color background = ui::BLACK; ui::Color background = ui::BLACK;
TRY(make<Window>(ui::Rect { 200, 200, 600, 400 }, ui::GREEN, "Calculator"_sv)); TRY(make<Window>(ui::Rect { 200, 200, 600, 400 }, ui::GREEN, "Calculator"_sv));
@ -96,7 +100,7 @@ Result<int> luna_main(int argc, char** argv)
int rc = poll(fds, 3, 1000); int rc = poll(fds, 3, 1000);
if (!rc) continue; if (!rc) continue;
if (rc < 0) { os::println("poll: error: %s", strerror(errno)); } if (rc < 0 && errno != EINTR) { os::println("poll: error: %s", strerror(errno)); }
if (fds[0].revents & POLLIN) if (fds[0].revents & POLLIN)
{ {