diff options
| author | 2022-11-24 04:25:27 -0800 | |
|---|---|---|
| committer | 2022-11-24 04:25:27 -0800 | |
| commit | 7bc20c994cec956a70d6a151c471c218632d1830 (patch) | |
| tree | 21881b24236bb512be159a09293b1111b27e79be /src | |
| parent | 033b8936c9a7a16defbf190a3209b831ca852221 (diff) | |
| download | bun-7bc20c994cec956a70d6a151c471c218632d1830.tar.gz bun-7bc20c994cec956a70d6a151c471c218632d1830.tar.zst bun-7bc20c994cec956a70d6a151c471c218632d1830.zip | |
Fix missing sigpipe handler
Diffstat (limited to 'src')
| -rw-r--r-- | src/crash_reporter.zig | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/crash_reporter.zig b/src/crash_reporter.zig index 4d98b47f4..0126c7f5e 100644 --- a/src/crash_reporter.zig +++ b/src/crash_reporter.zig @@ -27,7 +27,13 @@ noinline fn sigaction_handler(sig: i32, info: *const std.os.siginfo_t, _: ?*cons if (on_error) |handle| handle(sig, addr); } +noinline fn sigpipe_handler(_: i32, _: *const std.os.siginfo_t, _: ?*const anyopaque) callconv(.C) void { + const bun = @import("./global.zig"); + bun.Output.debug("SIGPIPE received\n", .{}); +} + pub fn reloadHandlers() !void { + try os.sigaction(os.SIG.PIPE, null, null); try setup_sigactions(null); var act = os.Sigaction{ @@ -37,6 +43,18 @@ pub fn reloadHandlers() !void { }; try setup_sigactions(&act); + + var pipe = os.Sigaction{ + .handler = .{ .sigaction = sigpipe_handler }, + .mask = os.empty_sigset, + .flags = (os.SA.SIGINFO | os.SA.RESTART | os.SA.RESETHAND), + }; + + try os.sigaction( + os.SIG.PIPE, + &pipe, + null, + ); } const os = std.os; pub fn start() !void { @@ -47,4 +65,17 @@ pub fn start() !void { }; try setup_sigactions(&act); + { + var pipe = os.Sigaction{ + .handler = .{ .sigaction = sigpipe_handler }, + .mask = os.empty_sigset, + .flags = (os.SA.SIGINFO | os.SA.RESTART | os.SA.RESETHAND), + }; + + try os.sigaction( + os.SIG.PIPE, + &pipe, + null, + ); + } } |
