Add interrupt handler

This commit is contained in:
Tyler Perkins 2021-08-23 15:44:02 -04:00
parent e85f0730a5
commit 2cfd43e2d7
3 changed files with 43 additions and 1 deletions

23
src/handler/handler.cpp Normal file
View File

@ -0,0 +1,23 @@
///////////////////////////////////////////////////////////////////////////////
// Tyler Perkins
// 8-23-21
// Handlers implementation
//
#include "handler.hpp"
namespace dashboard {
namespace handlers {
void intHandler(int dummy){
std::cerr << "Received, ctrl+c, quitting!\n";
exit(0);
}
void setHandlers(){
//go through and set every handler
std::signal(SIGINT, intHandler);
}
}
}

18
src/handler/handler.hpp Normal file
View File

@ -0,0 +1,18 @@
///////////////////////////////////////////////////////////////////////////////
// Tyler Perkins
// 8-23-21
// Handlers definitions
//
#pragma once
#include <csignal>
#include <iostream>
namespace dashboard {
namespace handlers {
void setHandlers();
void intHandler(int);
}
}

View File

@ -5,10 +5,11 @@
//
#include "config.hpp"
#include "handler/handler.hpp"
int main(int argc, char** argv){
dashboard::handlers::setHandlers();
return 0;