Just as with non-mac80211 devices, the stuff we do to enter monitor mode
doesn't automatically get cleaned up when the capture device is closed,
so we need to arrange that pcap_close_all() be called when we exit, to
close all the pcap_t's and turn off monitor mode.
*/
pcap_add_to_pcaps_to_close(handle);
*/
pcap_add_to_pcaps_to_close(handle);
+ /*
+ * If we haven't already done so, arrange to have
+ * "pcap_close_all()" called when we exit.
+ */
+ if (!pcap_do_addexit(handle)) {
+ /*
+ * "atexit()" failed; don't put the interface
+ * in rfmon mode, just give up.
+ */
+ return PCAP_ERROR_RFMON_NOTSUP;
+ }
+
return 1;
}
#endif /* HAVE_LIBNL */
return 1;
}
#endif /* HAVE_LIBNL */