event: Remove duplicated code when installing signal handlers

Change-Id: I8cb413cd18b738438f1b1b3e00a438e1323e8b1f
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/372170
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Ben Walker 2017-08-01 13:08:55 -07:00 committed by Jim Harris
parent 0fb41bb11f
commit c549377169

View File

@ -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");