diff -uNr wavemon-0.9.0/iw_scan.c wavemon-0.9.0.mod/iw_scan.c --- wavemon-0.9.0/iw_scan.c 2018-12-30 03:08:25.000000000 +0200 +++ wavemon-0.9.0.mod/iw_scan.c 2019-07-03 19:33:39.729820897 +0300 @@ -368,6 +368,10 @@ sr->num.ch_stats = n < MAX_CH_STATS ? n : MAX_CH_STATS; } +void on_exit_hook() { + if_set_down_on_exit(0, conf_ifname()); +} + /** The actual scan thread. */ void *do_scan(void *sr_ptr) { @@ -430,8 +434,7 @@ if (if_set_up(conf_ifname()) < 0) err_sys("Can not bring up interface '%s'", conf_ifname()); - if (on_exit(if_set_down_on_exit, (void *)conf_ifname()) < 0) - snprintf(sr->msg, sizeof(sr->msg), "Warning: unable to restore %s down state on exit", conf_ifname()); + atexit(on_exit_hook); break; } /* fall through */