tcpdump mailing list archives
Re: Should applications close pcap_get_selectable_fd()?
From: Michael Richardson <mcr () sandelman ca>
Date: Fri, 14 Aug 2026 15:48:36 -0400
Guy Harris <gharris () sonic net> wrote:
> On Aug 13, 2026, at 4:22 PM, Mark Delany <fzx () xray emu st> wrote:
>> This is probably more a documentation clarification than anything else as a light troll
>> through the archives suggests the answer...
>>
>> pcap_fileno(3) is fairly explicit about suggesting that the returned fd is the same one as
>> that used internally by pcap, however pcap_get_selectable_fd(3) is much less forthcoming
>> on the matter.
>>
>> My naive reading is that pcap_get_selectable_fd() returns a unique fd for my own purposes
>> and that I should close it when I'm done,
> The documentation needs to be changed to make it clearer that it should
> *not* be closed, because it could be, but is not guaranteed to be, the
> same file descriptor as the one used for the capture mechanism. (Some
> capture mechanism might require separate readable and selectable
> FDs. Npcap requires the Windows equivalent - a HANDLE on which to do
> reads, writes, and DeviceIoControl()s, and another HANDLE representing
> an event that can be waited on.)
Should one call pcap_get_selectable_fd() before each call to select()/poll()
or are applications allowed to cache it?
I don't think any implementation would change it, but probably we should be
explicit about that too.
_______________________________________________ tcpdump-workers mailing list -- tcpdump-workers () lists tcpdump org To unsubscribe send an email to tcpdump-workers-leave () lists tcpdump org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
Current thread:
- Should applications close pcap_get_selectable_fd()? Mark Delany (Aug 13)
- Re: Should applications close pcap_get_selectable_fd()? Guy Harris (Aug 13)
- Re: Should applications close pcap_get_selectable_fd()? Guy Harris (Aug 13)
- Re: Should applications close pcap_get_selectable_fd()? Mark Delany (Aug 13)
- Re: Should applications close pcap_get_selectable_fd()? Michael Richardson (Aug 14)
- Re: Should applications close pcap_get_selectable_fd()? Guy Harris (Aug 13)
