diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2024-06-10 15:08:09 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-10 15:08:09 +0100 |
| commit | 903e254e36b0f59aff4b2eb95345d1faea601ac3 (patch) | |
| tree | 39389436133060cb3ffb492322b8495ed7c4b72a | |
| parent | eef2aef021a039e627693c73c7962ed57f4ea073 (diff) | |
| parent | 71929f737bcb70db6875839b6beba020d84d24ff (diff) | |
Merge pull request #3725 from laytan/add-forced-shutdown-to-test-runner
add forced shutdown to new test runner
| -rw-r--r-- | core/testing/signal_handler_libc.odin | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/core/testing/signal_handler_libc.odin b/core/testing/signal_handler_libc.odin index d76fdd66b..0ab34776e 100644 --- a/core/testing/signal_handler_libc.odin +++ b/core/testing/signal_handler_libc.odin @@ -6,6 +6,7 @@ import "base:intrinsics" import "core:c/libc" import "core:encoding/ansi" import "core:sync" +import "core:os" @require import "core:sys/unix" @(private="file") stop_runner_flag: libc.sig_atomic_t @@ -20,7 +21,13 @@ local_test_index: libc.sig_atomic_t @(private="file") stop_runner_callback :: proc "c" (sig: libc.int) { - intrinsics.atomic_store(&stop_runner_flag, 1) + prev := intrinsics.atomic_add(&stop_runner_flag, 1) + + // If the flag was already set (if this is the second signal sent for example), + // consider this a forced (not graceful) exit. + if prev > 0 { + os.exit(int(sig)) + } } @(private="file") |