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 AC25343BF6; Mon, 26 Feb 2024 21:52:00 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5FBA342E57; Mon, 26 Feb 2024 21:51:56 +0100 (CET) Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by mails.dpdk.org (Postfix) with ESMTP id 7409A402CC for ; Mon, 26 Feb 2024 21:51:54 +0100 (CET) Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1dc0d11d1b7so27710745ad.2 for ; Mon, 26 Feb 2024 12:51:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1708980713; x=1709585513; 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=YCdLEaG5eE8vaeu+2OxtfS28AWX0rOgbRs8sMhWeP5k=; b=h9LM5TLN95z7fLWk2ztun8qRHLBfHhvhdR2xUv+lxhP0HwDbwWgO1seCdufg8V9CxA BK0qz/l1m110mgsWdo9MgVtU9FsJotp9ENDV1MhvbSoqEyH8oVuPT5MGg4UIGow7EudV ElSFLkxauGzfz9/oY7pTPsVaUkA4bWQeRlS2GBVeve+I+x7A6xN0i7ycHImytrRPO9GT MGx9aE5a33bd2RJe0fkaSEsUg+INLvQknmIt0XJsZ0v43Ma02sSVvEFMCtXJ5POXlMU8 j79r/RuysxX8DxawRkKG4Ra/15DhuXkbn02712il85atapOi41tqlnwO/efDq3czjEL3 eAUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708980713; x=1709585513; 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=YCdLEaG5eE8vaeu+2OxtfS28AWX0rOgbRs8sMhWeP5k=; b=IhD51KrEZwZzsaJjZqzc0wE8caodshzulDEx34RMCrsEacT0hYOsmwhALvtWr2C+vk 4sdoCDux83hLnXLhphrekYnQuP4cblj6j/zyqgh1BwBGsRq/SRNNQY7a6Y8FWmsHJQHe DzeDqDHzjbZ2WYwUcyAyL7iwtRq0HMOFfZDrx4MB0FfNHdTAjXRHcbCewr/MaK0QNlHg y7EoKAqqpvmWZFG0pFCDkBJpA2yQdl2guJ6hfDe3Kc9OURXhbl3W1QjyOMrSGcI6zxDk bq+r6U6C/BlA9TSJ1NIXR6zOxaudSA7PTvNnBcBMLZFw3PfoxcZ3PJ6wwkdaHRswqKDm +xUQ== X-Gm-Message-State: AOJu0YxDgLm3bc4yoyaLCmi9g7MF/iyPDPtPfvnqShIvea0HDdTE1xNu /7xSUGT1uifFXYWlRW0XjpjzIu9zfnn3fzezEXQcRglAxFVBP8erIsYCPJ5np8e0fw4F+RiDcdv u X-Google-Smtp-Source: AGHT+IFOEHcevhcYogYA8TVNDntNikwAKIzvQqR2BnyOny24ydPI1qzWm+2C5gDGxxA9bLGyUyU0xw== X-Received: by 2002:a17:903:2409:b0:1dc:81b8:cc1e with SMTP id e9-20020a170903240900b001dc81b8cc1emr7419844plo.60.1708980713650; Mon, 26 Feb 2024 12:51:53 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id 5-20020a170902ee4500b001db3efca159sm109615plo.132.2024.02.26.12.51.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 12:51:53 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Isaac Boukris , Reshma Pattan Subject: [PATCH 1/2] app/dumpcap: handle SIGTERM and SIGHUP Date: Mon, 26 Feb 2024 12:49:48 -0800 Message-ID: <20240226205143.66702-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240226205143.66702-1-stephen@networkplumber.org> References: <20240226205143.66702-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 application is killed (SIGTERM), or the console session ends (SIGHUP) or the write to the output file fails (SIGPIPE) then do cleanup before exiting. This also makes DPDK dumpcap behave more like Wireshark dumpcap. Suggested-by: Isaac Boukris 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 d57db0589a3f..76c747511444 100644 --- a/app/dumpcap/main.c +++ b/app/dumpcap/main.c @@ -939,6 +939,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; @@ -964,8 +969,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