From 1a4a3608c82fa847138a936e6063c278a0b0f31b Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Thu, 28 Aug 2025 10:58:35 +0200 Subject: [PATCH] exit the browser on SIGINT signal --- src/main.zig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main.zig b/src/main.zig index bd20ba72..85079bbb 100644 --- a/src/main.zig +++ b/src/main.zig @@ -41,6 +41,21 @@ pub fn main() !void { if (gpa.detectLeaks()) std.posix.exit(1); }; + // Exit the program on SIGINT signal. When running the browser in a Docker + // container, sending a CTRL-C (SIGINT) signal is catched but doesn't exit + // the program. Here we force exiting on SIGINT. + std.posix.sigaction(std.posix.SIG.INT, &std.posix.Sigaction{ + .handler = .{ + .handler = struct { + pub fn handler(_: c_int) callconv(.c) void { + std.posix.exit(0); + } + }.handler, + }, + .mask = std.posix.empty_sigset, + .flags = 0, + }, null); + run(alloc) catch |err| { // If explicit filters were set, they won't be valid anymore because // the args_arena is gone. We need to set it to something that's not