Commit e2bced6b authored by Jens Korinth's avatar Jens Korinth
Browse files

benchmark: Trap SIGINT and exit cleanly in case of exceptions

parent f274fe25
......@@ -11,6 +11,7 @@
#include <sstream>
#include <chrono>
#include <ctime>
#include <csignal>
#include <vector>
#include <sys/utsname.h>
#include <tapasco_api.hpp>
......@@ -60,7 +61,16 @@ struct job_throughput_t {
}; }
};
void signalHandler(int sig) {
cerr << "Signal %d received, aborting." << endl;
endwin();
exit(1);
}
int main(int argc, const char *argv[]) {
// trap ctrl-c
signal(SIGINT, signalHandler);
try {
Tapasco tapasco;
TransferSpeed tp { tapasco };
InterruptLatency il { tapasco };
......@@ -165,5 +175,9 @@ int main(int argc, const char *argv[]) {
ofstream f(argc >= 2 ? argv[1] : ss.str());
f << benchmark.dump();
f.close();
} catch (...) {
endwin();
throw;
}
}
/* vim: set foldmarker=@{,@} foldlevel=0 foldmethod=marker : */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment