From 3f173d0b6c85ce5fffdcbe3da3b01eef8192033e Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sun, 29 Sep 2019 15:31:28 +0200 Subject: 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 --- src/abort_handler.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/abort_handler.c (limited to 'src/abort_handler.c') 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 +#include +#include +#include + +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); + } +} + -- cgit v1.2.3