I'm developing an application on Debian 10, My application need to saving current data to a file before shut down. I cant handle event when system shutdown, any idea to help me resolve this problem?
Edit: That is my code
struct sigaction action;
memset(&action, 0, sizeof(action));
action.sa_handler = proc_term;
sigaction(SIGTERM, &action, NULL);
signal(SIGINT, proc_end);
signal(SIGTERM, proc_term);
Below is code for proc_term
function
void proc_term()
{
LOG_WARN("Process was force killed");
is_forcedexit = 1;
}