3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-26 10:39:23 +01:00

client: Use l_main_run_with_signal instead of open coding it

This commit is contained in:
Marcel Holtmann 2018-11-01 20:48:03 +01:00
parent 2b36727f3a
commit fe034229eb

View File

@ -31,8 +31,7 @@
#include "display.h" #include "display.h"
#include "dbus-proxy.h" #include "dbus-proxy.h"
static void signal_handler(struct l_signal *signal, uint32_t signo, static void signal_handler(uint32_t signo, void *user_data)
void *user_data)
{ {
switch (signo) { switch (signo) {
case SIGINT: case SIGINT:
@ -46,19 +45,11 @@ static void signal_handler(struct l_signal *signal, uint32_t signo,
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int exit_status; int exit_status;
struct l_signal *signal;
sigset_t mask;
bool interactive; bool interactive;
if (!l_main_init()) if (!l_main_init())
return EXIT_FAILURE; return EXIT_FAILURE;
sigemptyset(&mask);
sigaddset(&mask, SIGINT);
sigaddset(&mask, SIGTERM);
signal = l_signal_create(&mask, signal_handler, NULL, NULL);
l_log_set_stderr(); l_log_set_stderr();
interactive = command_init(argv, argc); interactive = command_init(argv, argc);
@ -68,7 +59,7 @@ int main(int argc, char *argv[])
dbus_proxy_init(); dbus_proxy_init();
l_main_run(); l_main_run_with_signal(signal_handler, NULL);
dbus_proxy_exit(); dbus_proxy_exit();
@ -78,8 +69,6 @@ int main(int argc, char *argv[])
exit_status = command_get_exit_status(); exit_status = command_get_exit_status();
command_exit(); command_exit();
l_signal_remove(signal);
l_main_exit(); l_main_exit();
return exit_status; return exit_status;