More thread termination clean-ups
diff --git a/honggfuzz.c b/honggfuzz.c
index 786f1eb..09484e3 100644
--- a/honggfuzz.c
+++ b/honggfuzz.c
@@ -55,7 +55,14 @@
return;
}
- sigReceived = sig;
+ if (ATOMIC_GET(sigReceived) != 0) {
+ static const char *const sigMsg = "Repeated termination signal caugth\n";
+ if (write(STDERR_FILENO, sigMsg, strlen(sigMsg) + 1) == -1) {
+ };
+ _exit(EXIT_FAILURE);
+ }
+
+ ATOMIC_SET(sigReceived, sig);
}
static void setupTimer(void)
@@ -184,7 +191,7 @@
if (hfuzz.useScreen) {
display_display(&hfuzz);
}
- if (sigReceived > 0) {
+ if (ATOMIC_GET(sigReceived) > 0) {
break;
}
if (ATOMIC_GET(hfuzz.threadsFinished) >= hfuzz.threadsMax) {
@@ -197,9 +204,10 @@
display_fini();
}
- if (sigReceived > 0) {
- LOG_I("Signal %d (%s) received, terminating", sigReceived, strsignal(sigReceived));
- return EXIT_SUCCESS;
+ if (ATOMIC_GET(sigReceived) > 0) {
+ LOG_I("Signal %d (%s) received, terminating", ATOMIC_GET(sigReceived),
+ strsignal(ATOMIC_GET(sigReceived)));
+ ATOMIC_SET(hfuzz.terminating, true);
}
fuzz_threadsStop(&hfuzz, threads);