]> The Tcpdump Group git mirrors - libpcap/blobdiff - pcap-linux.c
For mac80211 devices we need to clean up monitor mode on exit.
[libpcap] / pcap-linux.c
index 5079eb262518a0ee319c9c48bd9f6fab4f084b0f..e0238142427a394d7da324c5ead50dc37b3cf35b 100644 (file)
@@ -902,6 +902,18 @@ added:
         */
        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 */