From 543697847f2167152ae25f775f39541591b8d020 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Tue, 7 Jan 2025 11:00:44 -0600 Subject: [PATCH] Xwayland: don't inherit rlimit changes from river --- river/main.zig | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/river/main.zig b/river/main.zig index 4226e6a..2bb0ed5 100644 --- a/river/main.zig +++ b/river/main.zig @@ -84,7 +84,7 @@ pub fn main() anyerror!void { posix.exit(1); } } - const enable_xwayland = !result.flags.@"no-xwayland"; + const runtime_xwayland = !result.flags.@"no-xwayland"; const startup_command = blk: { if (result.flags.c) |command| { break :blk try util.gpa.dupeZ(u8, command); @@ -95,17 +95,25 @@ pub fn main() anyerror!void { log.info("river version {s}, initializing server", .{build_options.version}); - process.setup(); - river_init_wlroots_log(switch (runtime_log_level) { .debug => .debug, .info => .info, .warn, .err => .err, }); - try server.init(enable_xwayland); + try server.init(runtime_xwayland); defer server.deinit(); + // wlroots starts the Xwayland process from an idle event source, the reasoning being that + // this gives the compositor time to set up event listeners before Xwayland is actually + // started. We want Xwayland to be started by wlroots before we modify our rlimits in + // process.setup() since wlroots does not offer a way for us to reset the rlimit post-fork. + if (build_options.xwayland and runtime_xwayland) { + server.wl_server.getEventLoop().dispatchIdle(); + } + + process.setup(); + try server.start(); // Run the child in a new process group so that we can send SIGTERM to all