From cb01e5b2a190c21937bf8c87ad485d768f10a7ed Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 11 May 2022 08:13:38 +0200 Subject: tcpdump: Close pcap dumper at program exit Update #4649. --- freebsd/contrib/tcpdump/tcpdump.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/freebsd/contrib/tcpdump/tcpdump.c b/freebsd/contrib/tcpdump/tcpdump.c index 0438dd37..a02fa184 100644 --- a/freebsd/contrib/tcpdump/tcpdump.c +++ b/freebsd/contrib/tcpdump/tcpdump.c @@ -1269,6 +1269,13 @@ pcap_loop_wrapper(pcap_t *pd, int cnt, pcap_handler cb, u_char *ud) } #define pcap_loop(pd, cnt, cb, ud) pcap_loop_wrapper(pd, cnt, cb, ud) + +static void +destroy_pcap_dumper(void *arg) +{ + + pcap_dump_close(arg); +} #endif /* __rtems__ */ int #ifndef __rtems__ @@ -2125,6 +2132,12 @@ main(int argc, char **argv) if (Uflag) pcap_dump_flush(p); #endif +#ifdef __rtems__ + if (rtems_bsd_program_add_destructor(destroy_pcap_dumper, p) == + NULL) { + error("cannot add destructor"); + } +#endif /* __rtems__ */ } else { dlt = pcap_datalink(pd); ndo->ndo_if_printer = get_if_printer(ndo, dlt); -- cgit v1.2.3