DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Reshma Pattan <reshma.pattan@intel.com>
Subject: [PATCH v2 1/2] app/dumpcap: handle SIGTERM and SIGHUP
Date: Wed, 29 May 2024 09:08:06 -0700	[thread overview]
Message-ID: <20240529160933.282846-2-stephen@networkplumber.org> (raw)
In-Reply-To: <20240529160933.282846-1-stephen@networkplumber.org>

If the dumpcap is killed it does not cleanup which leaves
the ring buffer and the memory pool behind.
Until resource are exhausted devices will continue to fill the ring.

Fix by having the application handle SIGTERM, SIGHUP, and SIGPIPE.
These are the same signals handled in same way by the wireshark
dumpcap application.

Fixes: cbb44143be74 ("app/dumpcap: add new packet capture application")

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/dumpcap/main.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c
index b25b95e2fc..ba91ca94d0 100644
--- a/app/dumpcap/main.c
+++ b/app/dumpcap/main.c
@@ -936,6 +936,11 @@ int main(int argc, char **argv)
 {
 	struct rte_ring *r;
 	struct rte_mempool *mp;
+	struct sigaction action = {
+		.sa_flags = SA_RESTART,
+		.sa_handler = signal_handler,
+	};
+	struct sigaction origaction;
 	dumpcap_out_t out;
 	char *p;
 
@@ -961,8 +966,13 @@ int main(int argc, char **argv)
 
 	compile_filters();
 
-	signal(SIGINT, signal_handler);
-	signal(SIGPIPE, SIG_IGN);
+	sigemptyset(&action.sa_mask);
+	sigaction(SIGTERM, &action, NULL);
+	sigaction(SIGINT, &action, NULL);
+	sigaction(SIGPIPE, &action, NULL);
+	sigaction(SIGHUP, NULL, &origaction);
+	if (origaction.sa_handler == SIG_DFL)
+		sigaction(SIGHUP, &action, NULL);
 
 	enable_primary_monitor();
 
-- 
2.43.0


  reply	other threads:[~2024-05-29 16:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-26 20:49 [PATCH 0/2] dumpcap,pdump handle cleanup signals Stephen Hemminger
2024-02-26 20:49 ` [PATCH 1/2] app/dumpcap: handle SIGTERM and SIGHUP Stephen Hemminger
2024-02-26 20:49 ` [PATCH 2/2] app/pdump: " Stephen Hemminger
2024-02-27  9:59   ` Pattan, Reshma
2024-02-27 18:09     ` Stephen Hemminger
2024-05-29 16:08 ` [PATCH v2 0/2] Fix pdump and dumpcap leaks on SIGTERM Stephen Hemminger
2024-05-29 16:08   ` Stephen Hemminger [this message]
2024-05-29 16:08   ` [PATCH v2 2/2] app/pdump: handle SIGTERM and SIGHUP Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240529160933.282846-2-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=reshma.pattan@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).