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 1BAF6606A31C for ; Mon, 30 Nov 2026 00:29:27 +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=oo/CmX9K Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 088E540658; Mon, 30 Nov 2026 01:28:13 +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 09AA840A71 for ; Mon, 30 Nov 2026 01:28:10 +0100 (CET) Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-3b3a42a4bcdso3972731a91.0 for ; Sun, 29 Nov 2026 16:28:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20260707.gappssmtp.com; s=20260707; t=1795998488; x=1796603288; 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=oo/CmX9Kzmz+x0x15E9IaOMpYylNrVcU9hmOSHM3q7OtyQgkD7dTVEpWaBQJMvCZAa q+MMAtna0VR9TDq/QNik2NsfUf4Fyx/q5esJgc4DrE7SISRWlEFtl9asYGJX/zFcqbp3 CxQZNK15JrpN+zhJ5C536g5lPHgNBf4hwbYneAV5efoinutqwxz9JbbgcA1o16cFCAFR rwoc3OsV26QOQJ3OtE39ZboKEiYvsiY8mqR3rTat/q2uc/0QAR2ioQQMIYYJMt56fhbj KyT4bEcW0b6cz25Gt4WXbr79cqOSUjEaFJVYFpnxAHqRpl98wrHE51jNAV2uveqHk0JS IWWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795998488; x=1796603288; 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=F6ROfiA1Ye+h83Tovy/L2MkQk9+F4OxDCkpx4XXiatra9zrkICCHTjQMSE2evEjRoy jk2D91cixrzhHdwIMNUZmOcus1R4hSqMoYdKZ3MoqcI4kNZBuI6+zyD2ZjpbZ0S6sAq1 hdPAY2nWibs6Vg7s5EnKBencK0CamFbr2SFktohxXOkotJHBZomFdSwxODGmSphcRSwE 6IjAhSr0Eqe8/M5Pz9aUstm6QzjC41kbreCEQwlBo1CvmWJ19wvP/tccKW9USJ12Pe+H 2cPQvGRL49e3vWMktWNiKX3skN9w2ESr0klABjeTIB5rkxZBIJAFIzTTi9V/F1+gVcrt 9STg== X-Gm-Message-State: APuU4Z+ztERh9bx8X42nJkkOYgNnUack441rKXd2ncj5aa+ihSHWPzU7 UoK/Q7bZsBCxwPItstiU+z4K9OabVosu+xz1m4uwmzbT/dCqPMVUcvagtKek0lyuN/Pwl2+0pjK sPm3ziXc= X-Gm-Gg: AZFdTZdqVBFj80X8ImRiTHRwZvSjIOenf4GdOdXFaMXMjMY8kWkEu3M3cc9L5P9RJWp pCMCySRbQZOSaLrLy9Z3s7TkGg/c3UzfwYeju+hFEhbC6fl8JXoDP/Zyec0STri0odfW21CYqHs a6xNkiJHbWX+taovqAnMQA839wNuqAQiR/Lj6ByR8cUdvehrRUzRruu623TmnnJSGhN34BWM6zI 5BZerNhaur3XdXBI14SS3F3Dx6+3iTmvSxu7PF3HXrGVuZk4zjZgkvsSt+xHIesJGIvUkaLEjuW Hwo7iH2MeZvoSuZefi6h0t7QsJ9HZ3c8rfVQvM1i1gJdPfyFhp94wf4oc+7s0r/VlIKh3jtfP2C gYMA88+kTOFfvodBJK9IN3M116MWwEkOQ4vscu0+YlMq3yMKaG1MgmBBbwQTHQGDDHrOwMN5Ewr SwU/3LDDzBplYXdvSZc+Fi7zQ82ZmHGulu6oCEEzI5h6ngq7A5WF8gIUSiOwGYbSNwG/vt8Rsgr kpfYu7C6UyttQnVwW3GGBQDFj2q/J4/+LSbfF0OTp/zh4tj7swNeHCjuyui/AhV1BeFogM8WzqA lSa4Cka85ENLD4gXhLZZyj9TUTrnXTd/KHAl09e5wSvcrwek6j7Z5eVRP4Tvx36GG6T/ X-Received: by 2002:a17:90b:4ac5:b0:3ab:c80:936f with SMTP id 98e67ed59e1d1-3b41c8e16e3mr26336977a91.16.1795998488443; Sun, 29 Nov 2026 16:28:08 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 16:28:08 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Erik Gabriel Carrillo Subject: [PATCH 12/37] examples/timer: handle SIGINT and SIGTERM Date: Sun, 29 Nov 2026 16:26:57 -0800 Message-ID: <20261130002752.2342213-13-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 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