Skip to content

Instantly share code, notes, and snippets.

@lithdew
Created July 18, 2020 13:00
Show Gist options
  • Save lithdew/9d57472101e3b5a0f75cae4b210fa5c9 to your computer and use it in GitHub Desktop.
Save lithdew/9d57472101e3b5a0f75cae4b210fa5c9 to your computer and use it in GitHub Desktop.
zig: linux exit signal
var frame: anyframe = undefined;
pub fn main() !void {
print("Before\n", .{});
const handler = struct {
fn impl(sig: i32, info: *std.os.siginfo_t, ucontext: ?*c_void) callconv(.C) void {
resume frame;
}
};
const action = &std.os.Sigaction{
.sigaction = handler.impl,
.mask = std.os.empty_sigset,
.flags = 0,
.restorer = null,
};
std.os.sigaction(std.os.SIGINT, action, null);
suspend frame = @frame();
print("\nAfter\n", .{});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment