aboutsummaryrefslogtreecommitdiff
path: root/src/abort_handler.c
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2019-09-29 15:31:28 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2019-09-29 15:35:53 +0200
commit3f173d0b6c85ce5fffdcbe3da3b01eef8192033e (patch)
tree0c57769fd4b584b260b31af5d79cb5c5c8eed734 /src/abort_handler.c
parent059d263a6b944c4cfc5a5a0f2716e6a85116cfc1 (diff)
downloadallocbench-3f173d0b6c85ce5fffdcbe3da3b01eef8192033e.tar.gz
allocbench-3f173d0b6c85ce5fffdcbe3da3b01eef8192033e.zip
catch if cmd aborts
perf stat does not propagate if the measured cmd aborts. To solve thing in a universal way we register a SIGABRT handler which creates the file aborted
Diffstat (limited to 'src/abort_handler.c')
-rw-r--r--src/abort_handler.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/abort_handler.c b/src/abort_handler.c
new file mode 100644
index 0000000..8347f3a
--- /dev/null
+++ b/src/abort_handler.c
@@ -0,0 +1,21 @@
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void abort_handler(__attribute__((unused)) int signo) {
+ fopen("aborted", "w");
+}
+
+static void __attribute__((constructor)) register_abort_handler(void)
+{
+ struct sigaction sa;
+ sa.sa_handler = abort_handler;
+ sigemptyset(&sa.sa_mask);
+
+ if (sigaction(SIGABRT, &sa, NULL) == -1) {
+ perror("sigaction");
+ exit(1);
+ }
+}
+