kill zombies

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13013 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-04-14 02:29:34 +00:00
parent 41e011a5f9
commit d5bf92f159
1 changed files with 9 additions and 6 deletions

View File

@ -35,22 +35,25 @@
#include <stdlib.h> #include <stdlib.h>
#include <esl.h> #include <esl.h>
static void mycallback(esl_socket_t server_sock, esl_socket_t client_sock, struct sockaddr_in *addr) static void mycallback(esl_socket_t server_sock, esl_socket_t client_sock, struct sockaddr_in *addr)
{ {
esl_handle_t handle = {{0}}; esl_handle_t handle = {{0}};
char path_buffer[1024] = { 0 }; char path_buffer[1024] = { 0 };
const char *path; const char *path;
if (fork()) { if (fork()) {
close(client_sock); close(client_sock);
return; return;
} }
esl_attach_handle(&handle, client_sock, addr); esl_attach_handle(&handle, client_sock, addr);
if (!(path = esl_event_get_header(handle.info_event, "variable_ivr_path"))) { if (!(path = esl_event_get_header(handle.info_event, "variable_ivr_path"))) {
esl_disconnect(&handle);
esl_log(ESL_LOG_ERROR, "Missing ivr_path param!\n"); esl_log(ESL_LOG_ERROR, "Missing ivr_path param!\n");
return; exit(0);
} }
strncpy(path_buffer, path, sizeof(path_buffer) - 1); strncpy(path_buffer, path, sizeof(path_buffer) - 1);
@ -63,12 +66,10 @@ static void mycallback(esl_socket_t server_sock, esl_socket_t client_sock, struc
handle.sock = -1; handle.sock = -1;
esl_disconnect(&handle); esl_disconnect(&handle);
/* DOH! we're still here! Close the socket. */
execl(path_buffer, path_buffer, NULL); execl(path_buffer, path_buffer, NULL);
esl_log(ESL_LOG_ERROR, "Error %d\n", client_sock); //system(path_buffer);
close(client_sock); close(client_sock);
exit(0);
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@ -92,6 +93,8 @@ int main(int argc, char *argv[])
return -1; return -1;
} }
signal(SIGCHLD, SIG_IGN);
esl_listen(ip, port, mycallback); esl_listen(ip, port, mycallback);
return 0; return 0;