Clean up a couple of calls in main

Also add sighandler for SIGTERM
This commit is contained in:
Ben Buhse 2026-03-19 16:14:39 -05:00
commit fc60e3ac35
No known key found for this signature in database
GPG key ID: 7916ACFCD38FD0B4

View file

@ -91,6 +91,7 @@ pub fn main() !void {
fn run(wl_display: *wl.Display, context: *Context) !void { fn run(wl_display: *wl.Display, context: *Context) !void {
var mask = posix.sigemptyset(); var mask = posix.sigemptyset();
posix.sigaddset(&mask, posix.SIG.TERM);
posix.sigaddset(&mask, posix.SIG.INT); posix.sigaddset(&mask, posix.SIG.INT);
posix.sigaddset(&mask, posix.SIG.QUIT); posix.sigaddset(&mask, posix.SIG.QUIT);
@ -136,9 +137,8 @@ fn run(wl_display: *wl.Display, context: *Context) !void {
}; };
// Check for expired tag overlays and find the soonest expiry // Check for expired tag overlays and find the soonest expiry
const now = time.Instant.now() catch
fatal("System does not support a monotonic or steady clock", .{});
{ {
const now = time.Instant.now() catch fatal("System does not support a monotonic or steady clock", .{});
var it = context.wm.outputs.iterator(.forward); var it = context.wm.outputs.iterator(.forward);
while (it.next()) |output| { while (it.next()) |output| {
const tag_overlay = output.tag_overlay orelse continue; const tag_overlay = output.tag_overlay orelse continue;
@ -177,13 +177,15 @@ fn run(wl_display: *wl.Display, context: *Context) !void {
if (pollfds[poll_wayland].revents & posix.POLL.IN != 0) { if (pollfds[poll_wayland].revents & posix.POLL.IN != 0) {
if (wl_display.dispatch() != .SUCCESS) { if (wl_display.dispatch() != .SUCCESS) {
@branchHint(.cold); @branchHint(.cold);
fatal("Wayland display dispatch failed", .{}); log.err("Wayland display dispatch failed", .{});
break;
} }
} }
if (pollfds[poll_sig].revents & posix.POLL.HUP != 0) { if (pollfds[poll_sig].revents & posix.POLL.HUP != 0) {
@branchHint(.cold); @branchHint(.cold);
fatal("Signal fd hung up", .{}); log.err("Signal fd hung up", .{});
break;
} }
if (pollfds[poll_sig].revents & posix.POLL.IN != 0) { if (pollfds[poll_sig].revents & posix.POLL.IN != 0) {
@branchHint(.cold); @branchHint(.cold);