From 6d7f110566ee9c2f6828645f00c7f995fa9888d1 Mon Sep 17 00:00:00 2001 From: Guillaume Valadon <guillaume@valadon.net> Date: Mon, 24 Feb 2014 16:14:34 +0100 Subject: [PATCH] Close the file descriptor used to send packets --HG-- branch : Issue #371 --- scapy/arch/pcapdnet.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scapy/arch/pcapdnet.py b/scapy/arch/pcapdnet.py index 13bacc4a..f15c81aa 100644 --- a/scapy/arch/pcapdnet.py +++ b/scapy/arch/pcapdnet.py @@ -50,6 +50,8 @@ if conf.use_pcap: self.pcap = pcap.pcap(device, snaplen, promisc, immediate=1) def __getattr__(self, attr): return getattr(self.pcap, attr) + def __del__(self): + warning("__del__: don't know how to close the file descriptor. Bugs ahead ! Please report this bug.") open_pcap = lambda *args,**kargs: _PcapWrapper_pypcap(*args,**kargs) elif hasattr(pcap,"pcapObject"): # python-libpcap class _PcapWrapper_libpcap: @@ -66,6 +68,9 @@ if conf.use_pcap: return ts,pkt def __getattr__(self, attr): return getattr(self.pcap, attr) + def __del__(self): + fd = self.pcap.fileno() + os.close(fd) open_pcap = lambda *args,**kargs: _PcapWrapper_libpcap(*args,**kargs) elif hasattr(pcap,"open_live"): # python-pcapy class _PcapWrapper_pcapy: @@ -85,6 +90,8 @@ if conf.use_pcap: return 0 def __getattr__(self, attr): return getattr(self.pcap, attr) + def __del__(self): + warning("__del__: don't know how to close the file descriptor. Bugs ahead ! Please report this bug.") open_pcap = lambda *args,**kargs: _PcapWrapper_pcapy(*args,**kargs) -- GitLab