]> granicus.if.org Git - php/commitdiff
- Added support to break when signaling ctrl+c
authorFelipe Pena <felipensp@gmail.com>
Wed, 20 Nov 2013 19:16:07 +0000 (17:16 -0200)
committerFelipe Pena <felipensp@gmail.com>
Wed, 20 Nov 2013 19:16:07 +0000 (17:16 -0200)
phpdbg.c
phpdbg_prompt.c
phpdbg_prompt.h

index 3213ea3dcc5ff779f7993900f2d062f091e55927..6b219fa7561f7f413d8b53779106f4097c8260c2 100644 (file)
--- a/phpdbg.c
+++ b/phpdbg.c
@@ -17,6 +17,9 @@
    +----------------------------------------------------------------------+
 */
 
+#ifndef ZEND_SIGNALS
+# include <signal.h>
+#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;
index aaba7971f54e221039b266732e638697f1c5dc4a..f15c802feeb1e5ca24abe56d0bacaf3637c65098 100644 (file)
@@ -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) {
index c26dec2c34f672d53dbe9a894851c8867fef9ee6..e41ef624d2ef2a3197e8f901d73aabbdb51965b2 100644 (file)
 #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);