Created
July 18, 2020 13:00
-
-
Save lithdew/9d57472101e3b5a0f75cae4b210fa5c9 to your computer and use it in GitHub Desktop.
zig: linux exit signal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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