]> The Tcpdump Group git mirrors - libpcap/blobdiff - pcap-linux.c
Arrange to have pcap_close_all() earlier.
[libpcap] / pcap-linux.c
index e0238142427a394d7da324c5ead50dc37b3cf35b..d4f50b7d16e323df0e8afc438eb7a2f37482ece8 100644 (file)
@@ -861,6 +861,18 @@ added:
        nanosleep(&delay, NULL);
 #endif
 
+       /*
+        * 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;
+       }
+
        /*
         * Now configure the monitor interface up.
         */
@@ -902,18 +914,6 @@ 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 */