tcpdump mailing list archives
Should applications close pcap_get_selectable_fd()?
From: "Mark Delany" <fzx () xray emu st>
Date: Fri, 14 Aug 2026 09:22:09 +1000
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, however, almost exactly 16 years ago to the day,
Guy H, said:
"It returns either
1) the same FD that pcap_fileno() returns, if select() is supported on it"
so my naive reading is likely wrong.
Nonetheless, clarification would be good. Exactly who is responsible for closing the fds
returned by these calls? Do they get closed by pcap_close() or should the application
close them?
In either case, I suggest that both manpages be explicit about closing responsibilities
along the lines of "the returned file descriptor is closed by pcap_close()" or perhaps
being even more explicit about what an application can safely do with the file descriptor
without stomping on pcap.
Mark.
_______________________________________________
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)
