aboutsummaryrefslogtreecommitdiff
path: root/core/testing/signal_handler_libc.odin
diff options
context:
space:
mode:
authorLaytan Laats <laytanlaats@hotmail.com>2024-06-10 15:35:23 +0200
committerLaytan Laats <laytanlaats@hotmail.com>2024-06-10 15:35:23 +0200
commit71929f737bcb70db6875839b6beba020d84d24ff (patch)
tree396b26130bb17a66fd4f0f19ce69e316d3ca4cb4 /core/testing/signal_handler_libc.odin
parent7c529e990d815963df213145c1a5d6edecc969ad (diff)
add forced shutdown to new test runner
Currently, a Ctrl+c starts a graceful shutdown of the tests and runner. Sometimes tests get stuck and this would never complete. This simply adds an extra step, if Ctrl+c is given for the second time, just `os.exit` right away.
Diffstat (limited to 'core/testing/signal_handler_libc.odin')
-rw-r--r--core/testing/signal_handler_libc.odin9
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")