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 9CA8D606A31A for ; Mon, 30 Nov 2026 21:53:48 +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=fTdrl7G4 Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8FD5540A7D; Mon, 30 Nov 2026 22:52:26 +0100 (CET) Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by mails.dpdk.org (Postfix) with ESMTPS id 4565840671 for ; Mon, 30 Nov 2026 22:52:16 +0100 (CET) Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-8a052aff9e9so7828858b3a.0 for ; Mon, 30 Nov 2026 13:52:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20260707.gappssmtp.com; s=20260707; t=1796075535; x=1796680335; 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=+ACyz/AyKEaBwFSdRFGn6Hu0+hWxc66k8FBIPDIs/JU=; b=fTdrl7G4DpjGlGiVGbv0vg48BoN9U0Py0iOXt4634WBEXzKkac5ZOD9RjnCO+RGdbx DivchfX5xlNFIA6lNa0wYBeLrP9NT9/9rgbjGIqjNiQFy8wSm551zjeeasPS6kSm0Xkk mrcyB21ONjRWUF5/m8EaXWF5vVgXd34WQrz8uhPQ+H+HGki3yVDk+enA13UDO410E34F P8sAlPrMeVKHI7z/nxqT1Xos4I2FMH5kUE8SZJ0XSiC8CoEpDwSNd+AQ1INEePPuuwvN 4hEmdgT0JisW9x/CvQyHz03cR4ykliBdQxkp0UeI7t17DHvLkJMc0nL4MZAXhP48DFqp BR4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796075535; x=1796680335; 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=+ACyz/AyKEaBwFSdRFGn6Hu0+hWxc66k8FBIPDIs/JU=; b=X5mcply0qdH6DpDs5/9qeeoC7rkqgwyeLW/x3GOVgwGdSgPShGzJbrQslltBg9tV0l XLV+laftWrX+JrhO0sGMQJbpufMgmLNOz1TXcPm6LHJzysUaOniveW67V7FT12VgFTJK Vq3NEF182Ec1RaXbwwGrwgnCBJRnlvlvLm/AC79tDCBrIXKhETaZlEKInwOj9UzP25GM SayyJ7iFIJcRG8K2dDgoOJNFhRpUVyQZd3s6raiE+jhN/QYPcwPOcWJr6bKni08O1gEx HqDkASK+3P0ih4iOHoD+uczn0GZb1j/o3doxAfflsIkK0OFP8A1jlaOY2710GMVkHNNK ngMw== X-Gm-Message-State: APuU4Z/vg3+BH1YhdVSonwg4dTvZGQ55xMS5Ngqn0D82K8o8MlyPIHR7 Y6ENokbR5ovap6QS0Yyt0qnXf7sWJ3R9tmXTVjJEer4cZyTTimb8Cgkxv4o6ORwFX1oJ0iisMnV eawsaedg= X-Gm-Gg: AZFdTZfIsWHjUONNLgKAAueWdhT3WJowkt/utmL67mQkKm7sg7LXSAEa74Gr68oLK2M 0MEYvyikWgZcmT+ZHwmLeZ9RLQ4IePNvwx70IJ6M9jXEM0YrF5djPPHEhwU/iK/n0kYA1/NUOpP 6gjoUersf7DA4O8845NV/NdEjOoAbq4uvZR8Ja744e6bnByJE9A7FGzXCyJvs5eiiNQiLDrdD0M qqtophsHUjB2NTLJP+y+SSLheQTRubl5dvTdqnAQ6KB1LkbfJX/+CBU1uFkEN5YvVpPCrVZJpa5 zQrCtNIJ+QKklxgBb9MBXY075XTin4pzF1OhZD6mKvlPG8NDBaSq4m2pb8VNcE49owZnL5PB1PN TIu3/6e+KaOmxMXgBjIxGBDmXOs3PNaDxFxwIE3y5fWaCDB9HyDBk2rXFE8zTlHCxm/JsGVLdDK XWwJLxUKIXZAjPpYzNCeRxs7npBRBM7d6CiZ4bU2VHTsss2TpHvvAi28CAq/L47FfQePOoMWRIi HkvpfWvdtFq95k6BqIQh+HpCVBYRIQ6ZOf+6NOv612Zjv7NKMAU2KnYJAJehXCS3xefZHhaVcgg tJoa2qZXc4ykVDC7lMrLl7ExqmJKprIbm5sDtkeqit5xBj87WnEvnjUdYcv9kvBcd1v8 X-Received: by 2002:a05:6a00:2e91:b0:8b5:f313:9f40 with SMTP id d2e1a72fcca58-8c87d322aa5mr32897070b3a.49.1796075534708; Mon, 30 Nov 2026 13:52:14 -0800 (PST) Received: from phoenix.lan (204-195-112-43.wavecable.com. [204.195.112.43]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8c872e45756sm18561940b3a.27.2026.11.30.13.52.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 13:52:14 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v2 13/38] examples/timer: handle SIGINT and SIGTERM Date: Mon, 30 Nov 2026 13:49:19 -0800 Message-ID: <20261130215203.886245-14-stephen@networkplumber.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261130215203.886245-1-stephen@networkplumber.org> References: <20261129205006.1440292-1-stephen@networkplumber.org> <20261130215203.886245-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 timer poll loop in lcore_mainloop() 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 and now returns zero. lcore_mainloop() also runs on the worker lcores, so main() must wait for them to leave the loop before tearing down the EAL. Signed-off-by: Stephen Hemminger --- examples/timer/main.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/examples/timer/main.c b/examples/timer/main.c index a349846c7c..170c15ca19 100644 --- a/examples/timer/main.c +++ b/examples/timer/main.c @@ -2,6 +2,8 @@ * Copyright(c) 2010-2014 Intel Corporation */ +#include +#include #include #include #include @@ -56,7 +58,16 @@ timer1_cb(__rte_unused struct rte_timer *tim, } /* >8 End of timer1 callback. */ -static __rte_noreturn int +static volatile bool force_quit; + +static void +signal_handler(int signum) +{ + if (signum == SIGINT || signum == SIGTERM) + force_quit = true; +} + +static int lcore_mainloop(__rte_unused void *arg) { uint64_t prev_tsc = 0, cur_tsc, diff_tsc; @@ -66,7 +77,7 @@ lcore_mainloop(__rte_unused void *arg) printf("Starting mainloop on core %u\n", lcore_id); /* Main loop. 8< */ - while (1) { + while (!force_quit) { /* * Call the timer handler on each core: as we don't need a * very precise timer, so only call rte_timer_manage() @@ -81,6 +92,8 @@ lcore_mainloop(__rte_unused void *arg) } } /* >8 End of main loop. */ + + return 0; } int @@ -95,6 +108,9 @@ main(int argc, char **argv) if (ret < 0) rte_panic("Cannot init EAL\n"); + signal(SIGINT, signal_handler); + signal(SIGTERM, signal_handler); + /* init RTE timer library */ rte_timer_subsystem_init(); /* >8 End of init EAL. */ @@ -126,6 +142,9 @@ main(int argc, char **argv) (void) lcore_mainloop(NULL); /* >8 End of call lcore_mainloop() on every worker lcore. */ + /* wait for the workers to stop polling the timers */ + rte_eal_mp_wait_lcore(); + /* clean up the EAL */ rte_eal_cleanup(); -- 2.53.0