From 12f2bdf66a42c26e6e3a87c40a35415a7a44bd95 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 28 Nov 2011 16:45:59 -0600 Subject: [PATCH] FS-3724 2 ways to fix after updating to this version, 1) run set_zombie_exec in the dp; 2) use system_on_fax_success/system_on_fax_failure vars with explicit name of your command --- .../applications/mod_dptools/mod_dptools.c | 2 +- .../mod_spandsp/mod_spandsp_fax.c | 26 ++++++++++++++++++- src/switch_core.c | 5 +++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index ebe51c3a28..15913714fa 100755 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -4140,7 +4140,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) SWITCH_ADD_APP(app_interface, "bridge", "Bridge Audio", "Bridge the audio between two sessions", audio_bridge_function, "", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "system", "Execute a system command", "Execute a system command", system_session_function, "", - SAF_SUPPORT_NOMEDIA); + SAF_SUPPORT_NOMEDIA | SAF_ZOMBIE_EXEC); SWITCH_ADD_APP(app_interface, "say", "say", "say", say_function, SAY_SYNTAX, SAF_NONE); SWITCH_ADD_APP(app_interface, "wait_for_silence", "wait_for_silence", "wait_for_silence", wait_for_silence_function, WAIT_FOR_SILENCE_SYNTAX, diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c index db2134a725..5e1e90de69 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c @@ -316,6 +316,8 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result) char *fax_transfer_rate = NULL; char *fax_result_code = NULL; switch_event_t *event; + const char *var; + char *expanded; pvt = (pvt_t *) user_data; switch_assert(pvt); @@ -432,14 +434,36 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result) switch_event_fire(&event); } + if ((var = switch_channel_get_variable(channel, "system_on_fax_result"))) { + expanded = switch_channel_expand_variables(channel, var); + switch_system(expanded, SWITCH_FALSE); + if (expanded != var) { + free(expanded); + } + } + switch_channel_execute_on(channel, "execute_on_fax_result"); if (result == T30_ERR_OK) { + if ((var = switch_channel_get_variable(channel, "system_on_fax_success"))) { + expanded = switch_channel_expand_variables(channel, var); + switch_system(expanded, SWITCH_FALSE); + if (expanded != var) { + free(expanded); + } + } switch_channel_execute_on(channel, "execute_on_fax_success"); } else { + if ((var = switch_channel_get_variable(channel, "system_on_fax_failure"))) { + expanded = switch_channel_expand_variables(channel, var); + switch_system(expanded, SWITCH_FALSE); + if (expanded != var) { + free(expanded); + } + } switch_channel_execute_on(channel, "execute_on_fax_failure"); } - + } static int t38_tx_packet_handler(t38_core_state_t *s, void *user_data, const uint8_t *buf, int len, int count) diff --git a/src/switch_core.c b/src/switch_core.c index 506c983c5e..8a97de13a9 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -2408,6 +2408,7 @@ static int max_open(void) static int switch_system_fork(const char *cmd, switch_bool_t wait) { int pid; + char *dcmd = strdup(cmd); switch_core_set_signal_handlers(); @@ -2417,6 +2418,7 @@ static int switch_system_fork(const char *cmd, switch_bool_t wait) if (wait) { waitpid(pid, NULL, 0); } + free(dcmd); } else { int open_max = max_open(); int i; @@ -2426,7 +2428,8 @@ static int switch_system_fork(const char *cmd, switch_bool_t wait) } set_low_priority(); - i = system(cmd); + i = system(dcmd); + free(dcmd); exit(0); }