From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 972F044104; Wed, 29 May 2024 18:09:52 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CBC2B40695; Wed, 29 May 2024 18:09:47 +0200 (CEST) Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by mails.dpdk.org (Postfix) with ESMTP id 5E9474026F for ; Wed, 29 May 2024 18:09:46 +0200 (CEST) Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6f69422c090so1929294b3a.2 for ; Wed, 29 May 2024 09:09:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1716998985; x=1717603785; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PktQPsiNr3yn2laDOVgagY3gKznLHn4FO/k3AzDdvl8=; b=Gs1STB+sZE+JBR4iSuqA9d9HVbxLY5xMmntj4ItMqB7WPJYCEnAVehC+fHdekpnyOI 0XoQTBm4c2w2yCHk2WBBfE4n7BXLxtlZHrIvehPm7QkEasilou4QumiUGf6bOF9+zv/j A+PKuKDqD7Wg6jCRNaJVrC76T8pyCKiGD3L3gZCNTKW7CBgsu98oTLrDj4tdBLEEkHdl IQF31IVZrZ+eIpxrKOOA14DyDvHtwxg/rKpsRJ9jbmWnLDXf9odY/lvmlekp87209m0O Z35CfOGf93+Bi0nC+9E4OQCSdiMKCynbuJ2olc1s0MhEM0hJyvnYoN+NJnP3COFVAItY 75QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716998985; x=1717603785; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PktQPsiNr3yn2laDOVgagY3gKznLHn4FO/k3AzDdvl8=; b=KcFu+jcHQjfKq4SAl7w50lIJb3e6TQxKMWhga+vvDZvEZD3FE4Gl94MKTmtHMZEE3h sN24EgeAapDKMu+iriRHZUrMhwlqxbLrdYpzJ97GM4v1gCl6MI5pr60iZUdrA9QalB34 xBw1no7E3VlIgD4YKsgHjn81wF7ed2j2EWopTIlgXfyPrObkw2rRjgjHfOQO4Wa38S6b 2E6ioMG3PFNIyvlyV/qLtOYcNiJ0g7dR42HFPTJKrRiSFOcUesN7W0AGcJ4y0lPaaLFn HMYgLzJGIuP4OjqWYAL6QA9I4x7jhsfVXk3nLgjAf4kJSkCFVwcr/IQA+/Rw7AOljvpI o1RQ== X-Gm-Message-State: AOJu0YyT2e0fWE0zzHI3amYzuXYiB7H+7OuBPowys63Bn1rOug6GKvkD xbhwb9k2eey7X+nL3e31zsnxPOl4SlipduYTTUnABHTgPMrJkmqTBipF1yoRSa30S9Me6h4jKZN Q X-Google-Smtp-Source: AGHT+IHx+EpC1ViaW87Qxy+xOeqqFgCI3eRUk7t68rFpBt6TwSMXlw6OoNdNXKgMvSB1iweX8HadzA== X-Received: by 2002:a05:6a00:4c8b:b0:6ea:7468:1f31 with SMTP id d2e1a72fcca58-6f8f4192550mr17691585b3a.30.1716998985534; Wed, 29 May 2024 09:09:45 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-6be6cac52b9sm306713a12.70.2024.05.29.09.09.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 09:09:44 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan Subject: [PATCH v2 1/2] app/dumpcap: handle SIGTERM and SIGHUP Date: Wed, 29 May 2024 09:08:06 -0700 Message-ID: <20240529160933.282846-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240529160933.282846-1-stephen@networkplumber.org> References: <20240226205143.66702-1-stephen@networkplumber.org> <20240529160933.282846-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.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 --- 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