[v3,2/3] testpmd: use sig_atomic_t for flag
Checks
Commit Message
Standard conforming signal handling in applications should use sig_atomic_t
for flags set by signal handler.
https://www.gnu.org/software/libc/manual/html_node/Atomic-Data-Access.html
This is really just a fancy way of saying ''int'' but adds
to platform portablilty for DPDK.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/test-pmd/testpmd.c | 6 +-----
app/test-pmd/testpmd.h | 3 ++-
2 files changed, 3 insertions(+), 6 deletions(-)
Comments
On Tue, 14 Mar 2023 10:36:47 -0700
Stephen Hemminger <stephen@networkplumber.org> wrote:
> Standard conforming signal handling in applications should use sig_atomic_t
> for flags set by signal handler.
> https://www.gnu.org/software/libc/manual/html_node/Atomic-Data-Access.html
>
> This is really just a fancy way of saying ''int'' but adds
> to platform portablilty for DPDK.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Apparently, this fails on some distros because signal.h ends up including
some compatibility definitions that clash with the same definitions in
the ixgbe testpmd base code. Since fixing either base code or the distro
is a PIA not worth doing.
@@ -228,11 +228,7 @@ struct rte_eth_xstat_name *xstats_display;
unsigned int xstats_display_num; /**< Size of extended statistics to show */
-/*
- * In container, it cannot terminate the process which running with 'stats-period'
- * option. Set flag to exit stats period loop after received SIGINT/SIGTERM.
- */
-volatile uint8_t f_quit;
+volatile sig_atomic_t f_quit; /* Quit testpmd from signal */
uint8_t cl_quit; /* Quit testpmd from cmdline. */
/*
@@ -6,6 +6,7 @@
#define _TESTPMD_H_
#include <stdbool.h>
+#include <signal.h>
#ifdef RTE_LIB_GRO
#include <rte_gro.h>
@@ -34,7 +35,7 @@
#define RTE_PORT_HANDLING (uint16_t)3
extern uint8_t cl_quit;
-extern volatile uint8_t f_quit;
+extern volatile sig_atomic_t f_quit;
/*
* It is used to allocate the memory for hash key.