Commit 4bf95691 authored by Miguel Jimenez Lopez's avatar Miguel Jimenez Lopez

sw: Create a basic signal handler to disable interrupts in case of force exit

parent 223af9c2
......@@ -36,6 +36,6 @@ static void destroy_user_arguments(user_args args);
static void show_help(void);
static unsigned int check_user_stop(void);
static void set_stdin_as_nonblocking(void);
static void exit_abruptly(int sig);
#endif
......@@ -17,6 +17,7 @@
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <signal.h>
#include <fcntl.h>
#include <time.h>
......@@ -26,6 +27,9 @@
#include "file-log.h"
#include "irq-demo-private.h"
/* Static data for signal handlers */
static fmc_dio_device global_fmc_dev = NULL;
int main(int argc, char *argv[])
{
fmc_dio_device dev;
......@@ -38,6 +42,9 @@ int main(int argc, char *argv[])
stats_engine sengine;
int ret = 0;
signal(SIGINT, exit_abruptly);
signal(SIGQUIT, exit_abruptly);
gen_log = create_printf_log_device();
stats_log = create_file_log_device(STATS_LOG_PATH);
logs[0] = gen_log;
......@@ -72,6 +79,8 @@ int main(int argc, char *argv[])
set_stdin_as_nonblocking();
global_fmc_dev = dev;
while(!user_stop) {
demo_irq_process_loop(dev, sengine);
user_stop = check_user_stop();
......@@ -161,3 +170,9 @@ static void set_stdin_as_nonblocking(void)
{
fcntl (STDIN_FILENO, F_SETFL, O_NONBLOCK);
}
static void exit_abruptly(int sig)
{
disable_fmc_dio_device_all_irq(global_fmc_dev);
exit(0);
}
Markdown is supported
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