diff options
| author | shironeko <shironeko@tesaguri.club> | 2022-08-01 17:11:26 -0400 |
|---|---|---|
| committer | shironeko <shironeko@tesaguri.club> | 2022-08-10 20:44:22 -0400 |
| commit | 600fd2e73cbf55c1393061d4b74c4fba5d3f16ff (patch) | |
| tree | beb1b122dd43e1b85ab370404de2799255a40f8e | |
| parent | d4b2f2b0fc5766c8ae14a6f42fe76d058bfb3505 (diff) | |
| download | river-600fd2e73cbf55c1393061d4b74c4fba5d3f16ff.tar.gz river-600fd2e73cbf55c1393061d4b74c4fba5d3f16ff.tar.xz | |
river: ignore SIGPIPE to avoid weird exits
When river or wlroots write to a closed socket it could generate SIGPIPE
causing the whole desktop to seemingly "crash" with no error log of any
kind. So we ignore the SIGPIPE and just let the write fail with EPIPE to
be handled normally.
| -rw-r--r-- | river/main.zig | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/river/main.zig b/river/main.zig index b0e6579..53a17e5 100644 --- a/river/main.zig +++ b/river/main.zig @@ -41,7 +41,18 @@ const usage: []const u8 = pub var server: Server = undefined; +fn sa_handler(_: c_int) callconv(.C) void {} + pub fn main() anyerror!void { + // ignore SIGPIPE so we don't get killed when socket unexpectedly closes (thanks xwayland) + // use our own handler instead of SIG_IGN so we don't leak this when execve() + const act = os.Sigaction{ + .handler = .{ .handler = sa_handler }, + .mask = os.empty_sigset, + .flags = 0, + }; + os.sigaction(os.SIG.PIPE, &act, null); + // This line is here because of https://github.com/ziglang/zig/issues/7807 const argv: [][*:0]const u8 = os.argv; const result = flags.parse(argv[1..], &[_]flags.Flag{ |
