From 8c8c97fcb0acd34475f690e0bfa5777b01f180d8 Mon Sep 17 00:00:00 2001 From: William Robinet Date: Wed, 9 Dec 2020 15:13:15 +0100 Subject: [PATCH] Close global pcap struct properly in case of SIGINT --- base/pcap-snoop.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/base/pcap-snoop.c b/base/pcap-snoop.c index f89bf37..50f8748 100644 --- a/base/pcap-snoop.c +++ b/base/pcap-snoop.c @@ -126,10 +126,15 @@ int print_version() exit(0); } +pcap_t *p; void sig_handler(int sig) { fflush(stdout); - if (logger) logger->vtbl->deinit(); + if (logger) + logger->vtbl->deinit(); + printf("Cleaning %d remaining connection(s) from connection pool\n", destroy_all_conn()); + if(p) + pcap_close(p); exit(0); } @@ -276,7 +281,6 @@ int main(argc,argv) int argc; char **argv; { - pcap_t *p; int r; n_handler *n; #ifdef _WIN32