diff options
| author | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2024-05-30 17:02:32 -0400 |
|---|---|---|
| committer | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2024-06-02 14:54:31 -0400 |
| commit | fb37572c4ce9d8058cd73c0b7c21c1ecd2fdad65 (patch) | |
| tree | 4985b3073e4e8774cafeff30d25978dc1b7bccb8 /core/testing/signal_handler_libc.odin | |
| parent | 6050bc3bf66f5b2159f339a1b62f855fd774b966 (diff) | |
Rename `signal_handler.odin` to `signal_handler_libc.odin`
Diffstat (limited to 'core/testing/signal_handler_libc.odin')
| -rw-r--r-- | core/testing/signal_handler_libc.odin | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/core/testing/signal_handler_libc.odin b/core/testing/signal_handler_libc.odin new file mode 100644 index 000000000..2dd0ff192 --- /dev/null +++ b/core/testing/signal_handler_libc.odin @@ -0,0 +1,19 @@ +//+private +//+build windows, linux, darwin, freebsd, openbsd, netbsd, haiku +package testing + +import "base:intrinsics" +import "core:c/libc" + +@(private="file") +abort_flag: libc.sig_atomic_t + +setup_signal_handler :: proc() { + libc.signal(libc.SIGINT, proc "c" (sig: libc.int) { + intrinsics.atomic_add(&abort_flag, 1) + }) +} + +should_abort :: proc() -> bool { + return intrinsics.atomic_load(&abort_flag) > 0 +} |