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 EA56643BF6; Mon, 26 Feb 2024 21:52:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7478242E76; Mon, 26 Feb 2024 21:51:57 +0100 (CET) Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by mails.dpdk.org (Postfix) with ESMTP id 4B3E142E21 for ; Mon, 26 Feb 2024 21:51:55 +0100 (CET) Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1dc99a75be6so12549515ad.3 for ; Mon, 26 Feb 2024 12:51:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1708980714; x=1709585514; 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=ONDJULtuKfy2cHyiXCr/Q6vfY1X6kDA4bHcvcA37dr4=; b=dIEHT7iTRuPjwaJrflUTXd4DUie/qGV2qwN5TOPwfka2c32fEAKPm2uHyCkP3wPa9k jVvZ9I8GRg8Sd3q9rixB3GCeaSpNhfzR2VZwhPrsuAcd9px03uQyKqyY8sLEyqI68vw3 2u18RnLgTAm+sBa9BFuLbQc4BP+ElpVYDRfqSX4vJ1ERf3WI6V8tuTNgLdUKZl2lKw9k qsAYX7aspIiCj68AgER1/eYSgPpiVLF3wP/pCnPRWMW+Iv0uHiwBLEqHucANlptEvNII k88frkaTQvMg3jmbeXSZuh2R/RY6nXdXjHNF30IVRAt0Myhnp8TcCmunASSH9WIPRvYK c4rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708980714; x=1709585514; 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=ONDJULtuKfy2cHyiXCr/Q6vfY1X6kDA4bHcvcA37dr4=; b=ccKOKuQJcTXej03OpkkX3slXxnQZG0CNmLd5NnOFi/6eimX124cf40yD9MVzkPxbpg +qHMcdFVbkx2D8zFfVqzC7sDSQUVYcJRDcqqj5GJOAg9IGb7apHxs4VXorPHTXHm70MV J7+wC3JcVI5dQ/C6e7QGwCIdXdDIS6LjXGi+0EcvR2fx8xlnH4qj73JZ4epUoaCaBMD+ fA1U4wtB7MSibLr1e17QTtTT8ME6UDccy6J8ZWwx4OcbAS6JoAIRM4hZScPI/AU6u0MJ LUzvsV5+l1G2AIqbUXQeKaPsbDVd/snU6nv331KFHLZM7U2uk6nqN2i1HJsX6qEVfom9 3NnQ== X-Gm-Message-State: AOJu0YxEO61X0XuCIQTULmm1vO5udsGCJfaHxuaeDatklGOKSBMHbC78 05UhmH1hql3bEqtoxGvAhkchL3K4IL4svSpc/SSM2zkDVLIyIHbzJpc1IolVARnRuBOicQn23VQ I X-Google-Smtp-Source: AGHT+IEv1UGnXpWA3MNX0r7hQZ/S+A8fXRUpNRHI9ccX2RsvpbVxgr7gH8lU9MPpA8vpdaY+IXB56A== X-Received: by 2002:a17:902:a383:b0:1d9:8f6e:86e8 with SMTP id x3-20020a170902a38300b001d98f6e86e8mr7337685pla.69.1708980714445; Mon, 26 Feb 2024 12:51:54 -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:54 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan Subject: [PATCH 2/2] app/pdump: handle SIGTERM and SIGHUP Date: Mon, 26 Feb 2024 12:49:49 -0800 Message-ID: <20240226205143.66702-3-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 Like dumpcap, the pdump process should cleanup if process terminates due to being killed or hangup. Signed-off-by: Stephen Hemminger --- app/pdump/main.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/app/pdump/main.c b/app/pdump/main.c index a9205e130bb1..3592f8a865ad 100644 --- a/app/pdump/main.c +++ b/app/pdump/main.c @@ -571,11 +571,9 @@ disable_primary_monitor(void) } static void -signal_handler(int sig_num) +signal_handler(int sig_num __rte_unused) { - if (sig_num == SIGINT) { - quit_signal = 1; - } + quit_signal = 1; } static inline int @@ -975,6 +973,11 @@ enable_primary_monitor(void) int main(int argc, char **argv) { + struct sigaction action = { + .sa_flags = SA_RESTART, + .sa_handler = signal_handler, + }; + struct sigaction origaction; int diag; int ret; int i; @@ -983,8 +986,14 @@ main(int argc, char **argv) char mp_flag[] = "--proc-type=secondary"; char *argp[argc + 2]; - /* catch ctrl-c so we can print on exit */ - signal(SIGINT, signal_handler); + /* catch ctrl-c so we can cleanup on exit */ + 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); argp[0] = argv[0]; argp[1] = n_flag; -- 2.43.0