Add handler to panic on SIGSEGV to restore terminal to original state
This commit is contained in:
parent
108cc34fb6
commit
ba051a041d
11
src/pane.zig
11
src/pane.zig
@ -29,6 +29,10 @@ fn exit_signal(_: i32) callconv(.C) void {
|
||||
should_exit.store(true, .release);
|
||||
}
|
||||
|
||||
fn panic_signal(_: i32) callconv(.C) void {
|
||||
@panic("Segmentation fault!!");
|
||||
}
|
||||
|
||||
pub fn set_layout(layout: *Pane, initial_focus: *Pane) void {
|
||||
layout.parent = &window.pane;
|
||||
window.child = layout;
|
||||
@ -51,6 +55,13 @@ pub fn init(term_io: *TermIO) !void {
|
||||
};
|
||||
try std.posix.sigaction(std.posix.SIG.INT, &exit_handler, null);
|
||||
|
||||
var panic_handler = std.posix.Sigaction{
|
||||
.handler = .{ .handler = panic_signal },
|
||||
.mask = std.posix.empty_sigset,
|
||||
.flags = 0,
|
||||
};
|
||||
try std.posix.sigaction(std.posix.SIG.SEGV, &panic_handler, null);
|
||||
|
||||
term_io.enterRawMode();
|
||||
term_io.saveScreen();
|
||||
term_io.hideCursor();
|
||||
|
Loading…
Reference in New Issue
Block a user