mirror of https://github.com/nirenjan/libx52.git
Add signal handler to dump configuration to disk on SIGUSR1
parent
76b1b99717
commit
0899df60c2
|
@ -35,6 +35,12 @@ static void reload_handler(int signum)
|
||||||
flag_reload = true;
|
flag_reload = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static volatile bool flag_save_cfg;
|
||||||
|
static void save_config_handler(int signum)
|
||||||
|
{
|
||||||
|
flag_save_cfg = true;
|
||||||
|
}
|
||||||
|
|
||||||
static void set_log_file(bool foreground, const char *log_file)
|
static void set_log_file(bool foreground, const char *log_file)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
@ -137,6 +143,7 @@ static void start_daemon(bool foreground, const char *pid_file)
|
||||||
listen_signal(SIGTERM, termination_handler);
|
listen_signal(SIGTERM, termination_handler);
|
||||||
listen_signal(SIGQUIT, termination_handler);
|
listen_signal(SIGQUIT, termination_handler);
|
||||||
listen_signal(SIGHUP, reload_handler);
|
listen_signal(SIGHUP, reload_handler);
|
||||||
|
listen_signal(SIGUSR1, save_config_handler);
|
||||||
|
|
||||||
if (!foreground) {
|
if (!foreground) {
|
||||||
/* Fork off for the second time */
|
/* Fork off for the second time */
|
||||||
|
@ -303,6 +310,12 @@ int main(int argc, char **argv)
|
||||||
x52d_config_apply();
|
x52d_config_apply();
|
||||||
flag_reload = false;
|
flag_reload = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flag_save_cfg) {
|
||||||
|
PINELOG_INFO(_("Saving X52 configuration to disk"));
|
||||||
|
x52d_config_save(conf_file);
|
||||||
|
flag_save_cfg = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PINELOG_INFO(_("Received termination signal %s"), strsignal(flag_quit));
|
PINELOG_INFO(_("Received termination signal %s"), strsignal(flag_quit));
|
||||||
|
|
Loading…
Reference in New Issue