From: Felipe Pena Date: Wed, 20 Nov 2013 19:16:07 +0000 (-0200) Subject: - Added support to break when signaling ctrl+c X-Git-Tag: php-5.6.0alpha1~110^2~157 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c3f43f0a6ea77bdd9f7797e9d60ea2133c29a051;p=php - Added support to break when signaling ctrl+c --- diff --git a/phpdbg.c b/phpdbg.c index 3213ea3dcc..6b219fa756 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -17,6 +17,9 @@ +----------------------------------------------------------------------+ */ +#ifndef ZEND_SIGNALS +# include +#endif #include "phpdbg.h" #include "phpdbg_prompt.h" #include "phpdbg_bp.h" @@ -431,13 +434,6 @@ static void phpdbg_welcome(zend_bool cleaning TSRMLS_DC) /* {{{ */ } } /* }}} */ -void phpdbg_sigint_handler(int signo) -{ - TSRMLS_FETCH(); - PHPDBG_G(flags) |= PHPDBG_IS_SIGNALED; - phpdbg_notice("here"); -} - int main(int argc, char **argv) /* {{{ */ { sapi_module_struct *phpdbg = &phpdbg_sapi_module; @@ -610,18 +606,15 @@ phpdbg_main: phpdbg->ini_entries = ini_entries; if (phpdbg->startup(phpdbg) == SUCCESS) { -#ifdef ZEND_SIGNALS - zend_signal(SIGINT, phpdbg_sigint_handler); -#else - signal(SIGINT, phpdbg_sigint_handler); -#endif - zend_activate(TSRMLS_C); #ifdef ZEND_SIGNALS zend_try { - zend_signals_activate(TSRMLS_C); + zend_signal_activate(TSRMLS_C); + zend_signal(SIGINT, phpdbg_sigint_handler TSRMLS_CC); } zend_end_try(); +#else + signal(SIGINT, phpdbg_sigint_handler); #endif PG(modules_activated) = 0; diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index aaba7971f5..f15c802fee 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -1087,6 +1087,12 @@ void phpdbg_clean(zend_bool full TSRMLS_DC) /* {{{ */ } } /* }}} */ +void phpdbg_sigint_handler(int signo) +{ + TSRMLS_FETCH(); + PHPDBG_G(flags) |= PHPDBG_IS_SIGNALED; +} + static inline zend_execute_data *phpdbg_create_execute_data(zend_op_array *op_array, zend_bool nested TSRMLS_DC) /* {{{ */ { #if PHP_VERSION_ID >= 50500 @@ -1301,6 +1307,13 @@ zend_vm_enter: } next: + if (PHPDBG_G(flags) & PHPDBG_IS_SIGNALED) { + phpdbg_writeln(EMPTY); + phpdbg_notice("Program received signal SIGINT"); + PHPDBG_G(flags) &= ~PHPDBG_IS_SIGNALED; + DO_INTERACTIVE(); + } + PHPDBG_G(vmret) = execute_data->opline->handler(execute_data TSRMLS_CC); if (PHPDBG_G(vmret) > 0) { diff --git a/phpdbg_prompt.h b/phpdbg_prompt.h index c26dec2c34..e41ef624d2 100644 --- a/phpdbg_prompt.h +++ b/phpdbg_prompt.h @@ -20,14 +20,12 @@ #ifndef PHPDBG_PROMPT_H #define PHPDBG_PROMPT_H -/** - * Maximum command length - */ void phpdbg_init(char *init_file, size_t init_file_len, zend_bool use_default TSRMLS_DC); int phpdbg_interactive(TSRMLS_D); void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags TSRMLS_DC); int phpdbg_compile(TSRMLS_D); void phpdbg_clean(zend_bool full TSRMLS_DC); +void phpdbg_sigint_handler(int signo); #if PHP_VERSION_ID >= 50500 void phpdbg_execute_ex(zend_execute_data *execute_data TSRMLS_DC);