From e54c6680644995b3a29c9f6d856fda0f2faed07b Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Wed, 28 Jun 2023 11:12:33 +0900 Subject: [PATCH] display: Relocate SIGHUP handler When the deviced gets SIGHUP, display calls pm_save_logdump(). Move SIGHUP handler to the core because there is no reason for the same handler to exist in the all plugins. Change-Id: I794de3869520229ef87c8c6a4b4e3d3695d82214 Signed-off-by: Yunhee Seo --- plugins/iot-headed/display/core.c | 12 ------------ plugins/mobile/display/core.c | 12 ------------ plugins/tv/display/core.c | 12 ------------ plugins/wearable/display/core.c | 12 ------------ src/display/display.c | 13 +++++++++++++ 5 files changed, 13 insertions(+), 48 deletions(-) diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index bbc1382..4ae48ae 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -162,16 +162,6 @@ static const char* __device_flags_to_string(enum device_flags flags) return UNKNOWN_STR; } -/* SIGHUP signal handler - * For debug... print info to syslog - */ -static void sig_hup(int signo) -{ - _I("received sig hub %d", signo); - - pm_save_logdump(); -} - static void init_lcd_operation(void) { const struct device_ops *ops = NULL; @@ -337,8 +327,6 @@ static void display_init(void *data) _I("Start power manager."); - signal(SIGHUP, sig_hup); - /* load configutation */ ret = display_load_config(&display_conf); if (ret < 0) diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 49e0db2..e63af04 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -220,16 +220,6 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) return 0; } -/* SIGHUP signal handler - * For debug... print info to syslog - */ -static void sig_hup(int signo) -{ - _I("received sig hub %d", signo); - - pm_save_logdump(); -} - static void init_lcd_operation(void) { const struct device_ops *ops = NULL; @@ -391,8 +381,6 @@ static void display_init(void *data) _I("Start power manager."); - signal(SIGHUP, sig_hup); - /* load configutation */ ret = display_load_config(&display_conf); if (ret < 0) diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 635e3f3..5f72896 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -162,16 +162,6 @@ static const char* __device_flags_to_string(enum device_flags flags) return UNKNOWN_STR; } -/* SIGHUP signal handler - * For debug... print info to syslog - */ -static void sig_hup(int signo) -{ - _I("received sig hub %d", signo); - - pm_save_logdump(); -} - static void init_lcd_operation(void) { const struct device_ops *ops = NULL; @@ -334,8 +324,6 @@ static void display_init(void *data) _I("Start power manager."); - signal(SIGHUP, sig_hup); - /* load configutation */ ret = display_load_config(&display_conf); if (ret < 0) diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 5e03f28..16e8c4e 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -628,16 +628,6 @@ static int default_proc_change_state(unsigned int cond, pid_t pid) return 0; } -/* SIGHUP signal handler - * For debug... print info to syslog - */ -static void sig_hup(int signo) -{ - _I("received sig hub %d", signo); - - pm_save_logdump(); -} - /* * default transition function * 1. call check @@ -1132,8 +1122,6 @@ static void display_init(void *data) _I("Start power manager."); - signal(SIGHUP, sig_hup); - /* load configutation */ ret = display_load_config(&display_conf); if (ret < 0) diff --git a/src/display/display.c b/src/display/display.c index 3282a7f..200d23d 100644 --- a/src/display/display.c +++ b/src/display/display.c @@ -16,6 +16,8 @@ * limitations under the License. */ +#include + #include #include @@ -28,6 +30,7 @@ #include "display-misc.h" #include "display-signal.h" #include "display-state-transition.h" +#include "lock-detector.h" static const struct device_ops *display_plugin_device_ops; static int pm_cur_state; @@ -364,6 +367,15 @@ void display_set_initial_lockscreen_status(void) } } +static gboolean handle_sighup(gpointer data) +{ + int signo = (int) data; + _I("received sig hub %d", signo); + pm_save_logdump(); + + return G_SOURCE_REMOVE; +} + static int display_probe(void *data) { display_plugin_device_ops = find_device("display-plugin"); @@ -378,6 +390,7 @@ static void display_init(void *data) if (!display_plugin_device_ops || !display_plugin_device_ops->init) return; + g_unix_signal_add(SIGHUP, handle_sighup, (gpointer) SIGHUP); display_plugin_device_ops->init(data); display_signal_register_display_brightness_notifier(); -- 2.7.4