Skip to content

Commit eddabc3

Browse files
committed
exit the browser on SIGINT signal
1 parent 6800d50 commit eddabc3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/main.zig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,21 @@ pub fn main() !void {
4141
if (gpa.detectLeaks()) std.posix.exit(1);
4242
};
4343

44+
// Exit the program on SIGINT signal. When running the browser in a Docker
45+
// container, sending a CTRL-C (SIGINT) signal is catched but doesn't exit
46+
// the program. Here we force exiting on SIGINT.
47+
std.posix.sigaction(std.posix.SIG.INT, &std.posix.Sigaction{
48+
.handler = .{
49+
.handler = struct {
50+
pub fn handler(_: c_int) callconv(.C) void {
51+
std.posix.exit(0);
52+
}
53+
}.handler,
54+
},
55+
.mask = std.posix.empty_sigset,
56+
.flags = 0,
57+
}, null);
58+
4459
run(alloc) catch |err| {
4560
// If explicit filters were set, they won't be valid anymore because
4661
// the args_arena is gone. We need to set it to something that's not

0 commit comments

Comments
 (0)