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 0 : void notify_quit_handler(int sig)
11 : {
12 0 : slog(EVERY,"Notify quit!\n");
13 :
14 0 : atomic_store(&global_interrupt_flag,true);
15 :
16 0 : atomic_store(&global_return_status,HALTED);
17 :
18 0 : slog(EVERY,"The global return status and exit flag has been set to %s\n",show_status(global_return_status));
19 :
20 0 : if(sig==SIGTERM)
21 : {
22 0 : slog(EVERY,"Terminating the application. Please wait while the database will be closed smoothly…\n");
23 : }
24 :
25 0 : if(sig==SIGINT)
26 : {
27 0 : 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 0 : tcgetattr(fileno(stdin),&term);
33 0 : term.c_lflag |= (ICANON|ECHO);
34 0 : tcsetattr(fileno(stdin),0,&term);
35 0 : }
|