From 1604f08e33c8acf24aab21194684cb5685284f90 Mon Sep 17 00:00:00 2001 From: Brian West Date: Fri, 8 Apr 2011 13:46:02 -0500 Subject: [PATCH] rebind sighandlers --- src/include/switch_core.h | 1 + src/switch_core.c | 49 ++++++++++++++++++++---------------- src/switch_loadable_module.c | 2 ++ 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 684cc4f777..5a2b8992b2 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -2205,6 +2205,7 @@ SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_hand SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute(switch_cache_db_handle_t *dbh, const char *sql, uint32_t retries); SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_cache_db_handle_t *dbh, char *sql, uint32_t retries); +SWITCH_DECLARE(void) switch_core_set_signal_handlers(void); SWITCH_DECLARE(uint32_t) switch_core_debug_level(void); SWITCH_DECLARE(void) switch_cache_db_flush_handles(void); SWITCH_DECLARE(const char *) switch_core_banner(void); diff --git a/src/switch_core.c b/src/switch_core.c index 0ee4708a3d..623f1067a4 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -1772,27 +1772,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(switch_core_flag_t runtime.runlevel++; - /* set signal handlers */ - signal(SIGINT, SIG_IGN); -#ifdef SIGPIPE - signal(SIGPIPE, handle_SIGPIPE); -#endif -#ifdef SIGQUIT - signal(SIGQUIT, handle_SIGQUIT); -#endif -#ifdef SIGPOLL - signal(SIGPOLL, handle_SIGPOLL); -#endif -#ifdef SIGIO - signal(SIGIO, handle_SIGIO); -#endif -#ifdef TRAP_BUS - signal(SIGBUS, handle_SIGBUS); -#endif -#ifdef SIGUSR1 - signal(SIGUSR1, handle_SIGHUP); -#endif - signal(SIGHUP, handle_SIGHUP); + switch_core_set_signal_handlers(); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Bringing up environment.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Loading Modules.\n"); @@ -1806,6 +1786,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(switch_core_flag_t switch_load_core_config("post_load_switch.conf"); + switch_core_set_signal_handlers(); + if (switch_event_create(&event, SWITCH_EVENT_STARTUP) == SWITCH_STATUS_SUCCESS) { switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Event-Info", "System Ready"); switch_event_fire(&event); @@ -1869,6 +1851,31 @@ static void win_shutdown(void) } #endif +SWITCH_DECLARE(void) switch_core_set_signal_handlers(void) +{ + /* set signal handlers */ + signal(SIGINT, SIG_IGN); +#ifdef SIGPIPE + signal(SIGPIPE, handle_SIGPIPE); +#endif +#ifdef SIGQUIT + signal(SIGQUIT, handle_SIGQUIT); +#endif +#ifdef SIGPOLL + signal(SIGPOLL, handle_SIGPOLL); +#endif +#ifdef SIGIO + signal(SIGIO, handle_SIGIO); +#endif +#ifdef TRAP_BUS + signal(SIGBUS, handle_SIGBUS); +#endif +#ifdef SIGUSR1 + signal(SIGUSR1, handle_SIGHUP); +#endif + signal(SIGHUP, handle_SIGHUP); +} + SWITCH_DECLARE(uint32_t) switch_core_debug_level(void) { return runtime.debug_level; diff --git a/src/switch_loadable_module.c b/src/switch_loadable_module.c index 9804e53238..627aa46707 100644 --- a/src/switch_loadable_module.c +++ b/src/switch_loadable_module.c @@ -945,6 +945,8 @@ static switch_status_t switch_loadable_module_load_file(char *path, char *filena *new_module = module; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Successfully Loaded [%s]\n", module_interface->module_name); + switch_core_set_signal_handlers(); + return SWITCH_STATUS_SUCCESS; }