com php-src: - Added support to break when signaling ctrl+c: phpdbg.c phpdbg_prompt.c phpdbg_prompt.h
| From: | Bob Weinand | Date: | Wed, 20 Nov 2013 19:16:07 +0000 |
| Subject: | com php-src: - Added support to break when signaling ctrl+c: phpdbg.c phpdbg_prompt.c phpdbg_prompt.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-74741@lists.php.net to get a copy of this message | ||
Commit: c3f43f0a6ea77bdd9f7797e9d60ea2133c29a051
Author: Felipe Pena <felipensp@gmail.com> Wed, 20 Nov 2013 17:16:07 -0200
Parents: 9ba9abfa2aec0b679758879ab15eee801317dd44
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c3f43f0a6ea77bdd9f7797e9d60ea2133c29a051
Log:
- Added support to break when signaling ctrl+c
Changed paths:
M phpdbg.c
M phpdbg_prompt.c
M phpdbg_prompt.h
Diff:
diff --git a/phpdbg.c b/phpdbg.c
index 3213ea3..6b219fa 100644
--- 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;
diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c
index aaba797..f15c802 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 c26dec2..e41ef62 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);