diff options
author | Tuomas Taipale <tuomas.taipale@nokia.com> | 2024-03-05 07:38:54 +0000 |
---|---|---|
committer | Tuomas Taipale <95341842+TuomasTaipale@users.noreply.github.com> | 2024-03-14 14:52:23 +0200 |
commit | 0ec91223a9452904f7488ddd809ac8b1490bd772 (patch) | |
tree | 8b0cd54a69526a80c9414ab4a993bd248f2df0ab /test/performance/odp_l2fwd.c | |
parent | c41f7f0d4eba4a3d0546ad0205192009c0a93180 (diff) |
test: l2fwd: swap signal handler setup
Using `signal()` to setup signal handling should be avoided, so switch
to use `sigaction()`.
Signed-off-by: Tuomas Taipale <tuomas.taipale@nokia.com>
Reviewed-by: Matias Elo <matias.elo@nokia.com>
Diffstat (limited to 'test/performance/odp_l2fwd.c')
-rw-r--r-- | test/performance/odp_l2fwd.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c index 249286297..34d37da38 100644 --- a/test/performance/odp_l2fwd.c +++ b/test/performance/odp_l2fwd.c @@ -257,6 +257,16 @@ static void sig_handler(int signo ODP_UNUSED) odp_atomic_store_u32(&gbl_args->exit_threads, 1); } +static int setup_sig_handler(void) +{ + struct sigaction action = { .sa_handler = sig_handler }; + + if (sigemptyset(&action.sa_mask) || sigaction(SIGINT, &action, NULL)) + return -1; + + return 0; +} + /* * Drop packets which input parsing marked as containing errors. * @@ -2205,9 +2215,10 @@ int main(int argc, char *argv[]) init.mem_model = helper_options.mem_model; - /* Signal handler has to be registered before global init in case ODP - * implementation creates internal threads/processes. */ - signal(SIGINT, sig_handler); + if (setup_sig_handler()) { + ODPH_ERR("Signal handler setup failed\n"); + exit(EXIT_FAILURE); + } /* Init ODP before calling anything else */ if (odp_init_global(&instance, &init, NULL)) { |