Branch data Line data Source code
1 : : #include "precizer.h"
2 : :
3 : : /**
4 : : *
5 : : * Interrupt loops smoothly
6 : : * Interrupt when Ctrl+C (SIGTERM) or
7 : : * kill -15 (SIGINT)
8 : : *
9 : : */
10 : 4 : void signal_notify_quit_handler(int sig)
11 : : {
12 : 4 : slog(EVERY,"Notify quit!\n");
13 : :
14 : 4 : atomic_store(&global_interrupt_flag,true);
15 : :
16 : 4 : atomic_store(&global_return_status,HALTED);
17 : :
18 : 4 : slog(EVERY,"The global return status and exit flag has been set to %s\n",show_status(global_return_status));
19 : :
20 [ + + ]: 4 : if(sig==SIGTERM)
21 : : {
22 : 1 : slog(EVERY,"Terminating the application. Please wait while the database will be closed smoothly…\n");
23 : : }
24 : :
25 [ + + ]: 4 : if(sig==SIGINT)
26 : : {
27 : 3 : slog(EVERY,"Interrupting the application. Please wait while the database will be closed smoothly…\n");
28 : : }
29 : :
30 : : /// Enable key echo in terminal
31 : : struct termios term;
32 : 4 : tcgetattr(fileno(stdin),&term);
33 : 4 : term.c_lflag |= (ICANON|ECHO);
34 : 4 : tcsetattr(fileno(stdin),0,&term);
35 : 4 : }
|