3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-25 17:59:25 +01:00

hwsim: Use l_main_run_with_signal instead of open coding it

This commit is contained in:
Marcel Holtmann 2018-11-01 19:58:34 +01:00
parent a011909556
commit 36f5056810

View File

@ -2391,8 +2391,7 @@ static void hwsim_disappeared(void *user_data)
l_main_quit(); l_main_quit();
} }
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:
@ -2431,8 +2430,6 @@ static const struct option main_options[] = {
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
struct l_signal *signal;
sigset_t mask;
int actions = 0; int actions = 0;
for (;;) { for (;;) {
@ -2503,12 +2500,6 @@ int main(int argc, char *argv[])
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();
printf("Wireless simulator ver %s\n", VERSION); printf("Wireless simulator ver %s\n", VERSION);
@ -2543,9 +2534,7 @@ int main(int argc, char *argv[])
l_genl_family_set_watches(hwsim, hwsim_ready, hwsim_disappeared, l_genl_family_set_watches(hwsim, hwsim_ready, hwsim_disappeared,
NULL, NULL); NULL, NULL);
exit_status = EXIT_SUCCESS; exit_status = l_main_run_with_signal(signal_handler, NULL);
l_main_run();
l_genl_family_unref(hwsim); l_genl_family_unref(hwsim);
l_genl_family_unref(nl80211); l_genl_family_unref(nl80211);
@ -2561,7 +2550,6 @@ int main(int argc, char *argv[])
l_netlink_destroy(rtnl); l_netlink_destroy(rtnl);
done: done:
l_signal_remove(signal);
l_main_exit(); l_main_exit();
return exit_status; return exit_status;