-
Notifications
You must be signed in to change notification settings - Fork 107
Continue running the go program after exit() in PHP #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,7 @@ engine_context *context_new() { | |
| return context; | ||
| } | ||
|
|
||
| void context_exec(engine_context *context, char *filename) { | ||
| void context_exec(engine_context *context, char *filename, int *exit) { | ||
| int ret; | ||
|
|
||
| // Attempt to execute script file. | ||
|
|
@@ -48,9 +48,11 @@ void context_exec(engine_context *context, char *filename) { | |
| script.opened_path = NULL; | ||
| script.free_filename = 0; | ||
|
|
||
| ret = php_execute_script(&script); | ||
| ret = zend_execute_scripts(ZEND_REQUIRE, NULL, 1, &script); | ||
| *exit = -1; | ||
| } zend_catch { | ||
| errno = 1; | ||
| errno = 0; | ||
| *exit = EG(exit_status); | ||
| return; | ||
| } zend_end_try(); | ||
|
|
||
|
|
@@ -63,7 +65,7 @@ void context_exec(engine_context *context, char *filename) { | |
| return; | ||
| } | ||
|
|
||
| void *context_eval(engine_context *context, char *script) { | ||
| void *context_eval(engine_context *context, char *script, int *exit) { | ||
| zval *str = _value_init(); | ||
| _value_set_string(&str, script); | ||
|
|
||
|
|
@@ -84,7 +86,13 @@ void *context_eval(engine_context *context, char *script) { | |
|
|
||
| // Attempt to execute compiled string. | ||
| zval tmp; | ||
| _context_eval(op, &tmp); | ||
| _context_eval(op, &tmp, exit); | ||
|
|
||
| // Script called exit() | ||
| if (*exit != -1) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it may be possible to skip changing the signature of the version-specific functions ( |
||
| errno = 0; | ||
| return NULL; | ||
| } | ||
|
|
||
| // Allocate result value and copy temporary execution result in. | ||
| zval *result = malloc(sizeof(zval)); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ const char engine_ini_defaults[] = { | |
| "expose_php = 0\n" | ||
| "default_mimetype =\n" | ||
| "html_errors = 0\n" | ||
| "error_reporting = E_ALL\n" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hrm, this didn't have the desired effect of fixing the tests; unsure what is causing them to fail on Travis CI, then. However, these test failures have been around for a while looking at other pull requests.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, there have been some flaky tests that need fixing. I'll get on it. |
||
| "register_argc_argv = 1\n" | ||
| "implicit_flush = 1\n" | ||
| "output_buffering = 0\n" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ static void _context_bind(char *name, zval *value) { | |
| ZEND_SET_SYMBOL(EG(active_symbol_table), name, value); | ||
| } | ||
|
|
||
| static void _context_eval(zend_op_array *op, zval *ret) { | ||
| static void _context_eval(zend_op_array *op, zval *ret, int *exit) { | ||
| zend_op_array *oparr = EG(active_op_array); | ||
| zval *retval = NULL; | ||
| zval **retvalptr = EG(return_value_ptr_ptr); | ||
|
|
@@ -25,10 +25,9 @@ static void _context_eval(zend_op_array *op, zval *ret) { | |
|
|
||
| zend_try { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs to be |
||
| zend_execute(op); | ||
| *exit = -1; | ||
| } zend_catch { | ||
| destroy_op_array(op); | ||
| efree(op); | ||
| zend_bailout(); | ||
| *exit = EG(exit_status); | ||
| } zend_end_try(); | ||
|
|
||
| destroy_op_array(op); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see
php_execute_scriptdoes a bunch of other stuff but ends up callingzend_execute_scripts. Was this changed becausephp_execute_scriptwill truncateEG(exit_status)?