From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 815C4606A31C for ; Mon, 30 Nov 2026 00:29:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20260707.gappssmtp.com header.i=@networkplumber-org.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=c47wd0Au Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8100440A7D; Mon, 30 Nov 2026 01:28:11 +0100 (CET) Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by mails.dpdk.org (Postfix) with ESMTPS id 29A05406B8 for ; Mon, 30 Nov 2026 01:28:08 +0100 (CET) Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-3b439e37813so5023861a91.3 for ; Sun, 29 Nov 2026 16:28:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20260707.gappssmtp.com; s=20260707; t=1795998486; x=1796603286; 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:content-type; bh=ch+g9cDJseKod0tdesAnpNvbN7alBSraB3LkNzhYzjw=; b=c47wd0AujLsqoAsmSq7p29Acb7Bcs5FelWlLyhtm0yVcZ4bXyO1ob/+23cckJGRZ3c fnx0rqva92rb4N3foF18Mna6FUV83oD/VeiBfvrPjnEFNKcEXX9Va9ioZnWbZxbQOG1Y lPltlrmfwDOB7+/hRiL775oHzWAiPPcevJ4SlIAMed8srNIEXvQqxkeeC0EzVZX0E8xV r6jeJ17aK8CVOpxr9NDWVtA0d8hHGfHbyCj6USzMQf/tlIMbR9Sr5e4E7jrUhXITotDE PlR4P7f7jC53qkQPkgMR57KGcTXhWrVeWrm97oT/ObLnyK+sqYyn/xXCW7BXiIcQhAoM QHFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795998486; x=1796603286; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ch+g9cDJseKod0tdesAnpNvbN7alBSraB3LkNzhYzjw=; b=JccJpIq6prRTZWkvCkQu/T2/zO1DD7F9oXr/GtvcQXJ+VFZupZTVDI0ALYPwGibtJX OjY7Pn9A8+hW2+eRwWFQFNgipbBXdscTEmFPgw4OfyLC+Y9nyuDZ9gX5zDom3f5h6sne YgKlhy65ZmOWE29LZLmBhRUjWrKrEDzA4UBvhERIralVFTEMANhDo80JqYW0oFXOzKEN it+ICNW10dBPNHuuKeKm1a82Yu8V9Vltvc3IjnitEYJW9199T/oQ8EWza4EvTpYgd0t2 M82R7ebvxVp2fVpYGbcl6e+CnLEo0C1lM1DcS95XprE2U8k0+bllUI2a+XpH7jFHFFPu 4lww== X-Gm-Message-State: APuU4Z873sk17+Dz4TMuLAYvTlV0/kHqQV3RjhAE8yM7W8mfht61gxIk ZoI4N4NxCIupyPGIOAJoFbCzsZfTYecXFS8c284sYu834bBuOLnPZCR2bdcGERejWcu9luv6Y3/ togpe7js= X-Gm-Gg: AZFdTZcAUFAzP0q07n92mUHwZNFUTVEilDO9uzLvB9lgDRKo84k8k0vIiF0dHYfKLYP iF9Y39qxhnAKNVWmq6HP9oo8DUsvqc5zmXi+xy+jlfotsCnAFS1YpSpKT8erJwNej9Ylb5cKubb 7ZMa7uwU9y650NFMQ9bieCqh9nYX1df3w4npSBeWV1GxN3rngnaagaGinqwkpfbUTzeTzZG16ej wy5NPq3DJvDnSvejbs+Z5xJXrBNNcyslYgyU0AiU+/pbEKAlyvM0JrK2L1AACfXhFDVg8aYNs4t wIyuaUyuUFo1iHzrovvNbMFPwGOME2jdP6dJNEC0rzfcPG3kIrXp1quu0xoEaLWX7wAkM+7KiDL 8LVIAX29waLa/7wDnnJMxcU416NqEvMsPQCAeec8r9FbErttwntU5T2XZB1jHYBKJI495lAxV7q Jj4cm+gKhPdV2rUok+FkjOPVq86yfQ09iZ0QRAaArcrSQLabTzd33TQ1YtV4uKORgt+xmwjRAQG FXm4047W8ggo4LKd1CPCJi92muhc1XSiufdQboCsYEvnc50VmFdvxG71Uh/gmjjchlhYJnLROXg WPxVmP0kJcfYPkH/ylDiYm8sz3316mqfUNR10KmO98vio3f0j9epplu/U7uBb8HUh+0UE0ZTsRm TyEXAyN11VjudnQ== X-Received: by 2002:a17:90b:3e48:b0:3ac:adce:60ad with SMTP id 98e67ed59e1d1-3b41c98a343mr27210026a91.22.1795998486560; Sun, 29 Nov 2026 16:28:06 -0800 (PST) Received: from phoenix.lan (204-195-112-43.wavecable.com. [204.195.112.43]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b44b21e19fsm19455840a91.0.2026.11.29.16.28.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 16:28:05 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson , John McNamara Subject: [PATCH 10/37] examples/rxtx_callbacks: handle SIGINT and SIGTERM Date: Sun, 29 Nov 2026 16:26:55 -0800 Message-ID: <20261130002752.2342213-11-stephen@networkplumber.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261130002752.2342213-1-stephen@networkplumber.org> References: <20261130002752.2342213-1-stephen@networkplumber.org> X-Archived-By: 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-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 The forwarding loop in lcore_main() never terminates, so the rte_eal_cleanup() and return in main() are unreachable. Clang reports this with -Wunreachable-code. Add a signal handler setting force_quit, as done by l2fwd and others, and test it in the loop. The function is no longer __rte_noreturn, so the existing cleanup now runs on exit. Signed-off-by: Stephen Hemminger --- examples/rxtx_callbacks/main.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/examples/rxtx_callbacks/main.c b/examples/rxtx_callbacks/main.c index 4682921285..fe26e7cde2 100644 --- a/examples/rxtx_callbacks/main.c +++ b/examples/rxtx_callbacks/main.c @@ -2,7 +2,9 @@ * Copyright(c) 2010-2015 Intel Corporation */ +#include #include +#include #include #include #include @@ -23,6 +25,15 @@ static int hwts_dynfield_offset = -1; +static volatile bool force_quit; + +static void +signal_handler(int signum) +{ + if (signum == SIGINT || signum == SIGTERM) + force_quit = true; +} + static inline rte_mbuf_timestamp_t * hwts_field(struct rte_mbuf *mbuf) { @@ -244,7 +255,7 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool) * Main thread that does the work, reading from INPUT_PORT * and writing to OUTPUT_PORT */ -static __rte_noreturn void +static void lcore_main(void) { uint16_t port; @@ -259,7 +270,7 @@ lcore_main(void) printf("\nCore %u forwarding packets. [Ctrl+C to quit]\n", rte_lcore_id()); - for (;;) { + while (!force_quit) { RTE_ETH_FOREACH_DEV(port) { struct rte_mbuf *bufs[BURST_SIZE]; const uint16_t nb_rx = rte_eth_rx_burst(port, 0, @@ -301,6 +312,10 @@ main(int argc, char *argv[]) if (ret < 0) rte_exit(EXIT_FAILURE, "Error with EAL initialization\n"); + + signal(SIGINT, signal_handler); + signal(SIGTERM, signal_handler); + argc -= ret; argv += ret; -- 2.53.0