[Toxine-cvs] CVS: toxine/src commands.c,1.66,1.67 common.h,1.28,1.29 main.c,1.32,1.33
Brought to you by:
f1rmb
From: Daniel Caujolle-B. <f1...@us...> - 2004-05-17 21:23:49
|
Update of /cvsroot/toxine/toxine/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4757 Modified Files: commands.c common.h main.c Log Message: fix C-c segfault. Index: commands.c =================================================================== RCS file: /cvsroot/toxine/toxine/src/commands.c,v retrieving revision 1.66 retrieving revision 1.67 diff -u -r1.66 -r1.67 --- commands.c 17 May 2004 20:31:42 -0000 1.66 +++ commands.c 17 May 2004 21:23:35 -0000 1.67 @@ -663,26 +663,6 @@ } /* - * Handle signals event. - */ -static void toxine_signals_handler (int sig) { - - switch(sig) { - /* Kill the line on C-c */ - case SIGINT: - case SIGTERM: - if(rl_prompt) { /* readline is running, otherwise we are in script mode */ - rl_kill_full_line(1, 1); - rl_redisplay(); - } - else - exit(1); - break; - - } -} - -/* * Handle user entered commands. */ void toxine_handle_command(toxine_t *tox, void *data) { Index: common.h =================================================================== RCS file: /cvsroot/toxine/toxine/src/common.h,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- common.h 17 May 2004 19:53:24 -0000 1.28 +++ common.h 17 May 2004 21:23:35 -0000 1.29 @@ -23,6 +23,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <signal.h> #include <limits.h> #include <pthread.h> @@ -182,6 +183,7 @@ } mediamark_t; struct toxine_s { + pid_t pid; int argc; char **argv; @@ -283,4 +285,6 @@ char *syntax; }; +void toxine_signals_handler (int sig); + #endif Index: main.c =================================================================== RCS file: /cvsroot/toxine/toxine/src/main.c,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- main.c 17 May 2004 20:31:43 -0000 1.32 +++ main.c 17 May 2004 21:23:35 -0000 1.33 @@ -42,6 +42,8 @@ # include "getopt.h" #endif +#include <readline.h> + #include <xine.h> #include <xine/xineutils.h> @@ -69,6 +71,33 @@ }; /* + * Handle signals event. + */ +void toxine_signals_handler (int sig) { + pid_t pid = getppid(); + + if(pid == tox->pid) { + + switch(sig) { + /* Kill the line on C-c */ + case SIGINT: + case SIGTERM: + case SIGQUIT: + if(rl_prompt) { /* readline is running, otherwise we are in script mode */ + rl_kill_full_line(1, 1); + rl_redisplay(); + } + else { + tox->video.running = tox->running = 0; + exit(1); + } + break; + + } + } +} + +/* * Display version/copyright banner. */ static void toxine_show_version(toxine_t *tox) { @@ -189,6 +218,7 @@ tox = (toxine_t *) xine_xmalloc(sizeof(toxine_t)); + tox->pid = getppid(); tox->command.remain = NULL; tox->command.line = NULL; tox->command.command = NULL; |