From c54937716972700b889a1c6c0c9c05ca945cf882 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Tue, 1 Aug 2017 13:08:55 -0700 Subject: [PATCH] event: Remove duplicated code when installing signal handlers Change-Id: I8cb413cd18b738438f1b1b3e00a438e1323e8b1f Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/372170 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Jim Harris --- lib/event/app.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/event/app.c b/lib/event/app.c index 9821c9582..07e3cb172 100644 --- a/lib/event/app.c +++ b/lib/event/app.c @@ -291,10 +291,10 @@ spdk_app_start(struct spdk_app_opts *opts, spdk_event_fn start_fn, } sigemptyset(&sigmask); - memset(&sigact, 0, sizeof(sigact)); - sigact.sa_handler = SIG_IGN; sigemptyset(&sigact.sa_mask); + + sigact.sa_handler = SIG_IGN; rc = sigaction(SIGPIPE, &sigact, NULL); if (rc < 0) { SPDK_ERRLOG("sigaction(SIGPIPE) failed\n"); @@ -302,8 +302,9 @@ spdk_app_start(struct spdk_app_opts *opts, spdk_event_fn start_fn, exit(EXIT_FAILURE); } + /* Install the same handler for SIGINT and SIGTERM */ sigact.sa_handler = __shutdown_signal; - sigemptyset(&sigact.sa_mask); + rc = sigaction(SIGINT, &sigact, NULL); if (rc < 0) { SPDK_ERRLOG("sigaction(SIGINT) failed\n"); @@ -312,8 +313,6 @@ spdk_app_start(struct spdk_app_opts *opts, spdk_event_fn start_fn, } sigaddset(&sigmask, SIGINT); - sigact.sa_handler = __shutdown_signal; - sigemptyset(&sigact.sa_mask); rc = sigaction(SIGTERM, &sigact, NULL); if (rc < 0) { SPDK_ERRLOG("sigaction(SIGTERM) failed\n"); @@ -324,7 +323,6 @@ spdk_app_start(struct spdk_app_opts *opts, spdk_event_fn start_fn, if (opts->usr1_handler != NULL) { sigact.sa_handler = opts->usr1_handler; - sigemptyset(&sigact.sa_mask); rc = sigaction(SIGUSR1, &sigact, NULL); if (rc < 0) { SPDK_ERRLOG("sigaction(SIGUSR1) failed\n");