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 4640145562; Wed, 3 Jul 2024 17:47:24 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0F7D242E5A; Wed, 3 Jul 2024 17:47:20 +0200 (CEST) Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by mails.dpdk.org (Postfix) with ESMTP id 3E5D540F16 for ; Wed, 3 Jul 2024 17:47:18 +0200 (CEST) Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1fa244db0b2so44763615ad.3 for ; Wed, 03 Jul 2024 08:47:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1720021637; x=1720626437; 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=k0+TS2GRieIaX4/LjJV2139qBpArgr2HZtR3CCw6UfMQXqN/UqWNjGfZ1RngJpn0bd S7xiN3nFFGL7Zu+3/dsRiBNmcpB8prWjhMpCXCbSB4TNqTPSawPLc7Pcxpro6wD/Uuch /OzQ4NCe3N0Ad23huINsIwxKK4WA25quIkz2BXMdkcP1F5Bxih7XM4r6QwMMf5fh0Rq+ +QJx/wuUrKNm9m3gM/CBVzl+XXrVlEXHUUXrZk0FaCvCHMY2z2ypCmhKY+nx5SViF1BU mwm37TNVdVrfBinrUChpdFRf5doWTu2na17UaMeU58qrhdFiDLV8uaDsevDmcfPguZQc Jy/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720021637; x=1720626437; 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=lNPggJ09B5GM4umLAUmkAjfAWXNP9m1QBQIotlg9+7kUpDoCPs7q6NHswppMVcRSgX BFOOaptrUOgqGTgdzkkYENUclf1CLbks9ueWudhx/3pA38Ttb7QciWnftVVYCoo65CGQ tP8rI5+YO/1pUvMXliE1YqWV3TuiTEpMJ2pdhhicwzEnJ6yIfn3mRixtP89Df6UDkio7 6TCeeaZEfrRR0RkryMaK3mnorh5Mha9FgxAuEtLQK9+rBJx0E9EL8Khv7M7OTbaxEesZ 9rl/EQTbyvcmBoh0OKjEri+ThO/UM2FjEchh31eC87hF7BrDBx+OcKBtluK2iDprRgIq 7cZg== X-Gm-Message-State: AOJu0YyLOWMLXv9v0sZBSoo4kCfQyK6253ifEty2lKoP3YzWHkf6FKzr 4CPS/WbbiNUpFyYeb8VH1lpYJKMdRr+6solvHvhgPhompyAvSJopnrel7IzNTLW42OWNbO/1szX NcnU= X-Google-Smtp-Source: AGHT+IGw5JJFw+i4NYxjvCiUQNvc4TaRXUbz0DGUzSJcfO2DrYkniNXHBtrrIyozCG1YfxafORfgRQ== X-Received: by 2002:a17:902:d489:b0:1f9:c508:acdf with SMTP id d9443c01a7336-1fadbc686f0mr83621385ad.13.1720021637376; Wed, 03 Jul 2024 08:47:17 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fb0bd80588sm24653345ad.7.2024.07.03.08.47.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 08:47:16 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan Subject: [PATCH v3 1/3] app/dumpcap: handle SIGTERM and SIGHUP Date: Wed, 3 Jul 2024 08:45:43 -0700 Message-ID: <20240703154705.19192-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240703154705.19192-1-stephen@networkplumber.org> References: <20240529160933.282846-1-stephen@networkplumber.org> <20240703154705.19192-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