diff --git a/.appveyor.yml b/.appveyor.yml index 68f1bdf86a5e3..d9bb802b75e0f 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -20,6 +20,12 @@ cache: - c:\build-cache - c:\build-cache\sdk -> .appveyor.yml +init: + - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) + +on_finish: + - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) + environment: PHP_BUILD_CACHE_BASE_DIR: c:\build-cache PHP_BUILD_OBJ_DIR: c:\obj diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 000348d4754f3..707a84f9198d1 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -671,40 +671,12 @@ ZEND_FUNCTION(error_reporting) ZEND_PARSE_PARAMETERS_END(); old_error_reporting = EG(error_reporting); - if (ZEND_NUM_ARGS() != 0) { + if(ZEND_NUM_ARGS() != 0) { zend_string *new_val = zval_get_string(err); - do { - zend_ini_entry *p = EG(error_reporting_ini_entry); - - if (!p) { - p = zend_hash_find_ptr(EG(ini_directives), ZSTR_KNOWN(ZEND_STR_ERROR_REPORTING)); - if (p) { - EG(error_reporting_ini_entry) = p; - } else { - break; - } - } - if (!p->modified) { - if (!EG(modified_ini_directives)) { - ALLOC_HASHTABLE(EG(modified_ini_directives)); - zend_hash_init(EG(modified_ini_directives), 8, NULL, NULL, 0); - } - if (EXPECTED(zend_hash_add_ptr(EG(modified_ini_directives), ZSTR_KNOWN(ZEND_STR_ERROR_REPORTING), p) != NULL)) { - p->orig_value = p->value; - p->orig_modifiable = p->modifiable; - p->modified = 1; - } - } else if (p->orig_value != p->value) { - zend_string_release(p->value); - } - - p->value = new_val; - if (Z_TYPE_P(err) == IS_LONG) { - EG(error_reporting) = Z_LVAL_P(err); - } else { - EG(error_reporting) = atoi(ZSTR_VAL(p->value)); - } - } while (0); + zend_string *ini_name; + ini_name = zend_string_init("error_reporting", sizeof("error_reporting") - 1, 0); + zend_alter_ini_entry(ini_name, new_val, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); + zend_string_release(ini_name); } RETVAL_LONG(old_error_reporting); diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index 6d048091c5a4c..3835188d30954 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -258,10 +258,26 @@ PHP_FUNCTION(proc_terminate) } #ifdef PHP_WIN32 - if (TerminateProcess(proc->childHandle, 255)) { - RETURN_TRUE; + // Special WIN32 handling with SIGUSER1 and SIGUSR2 to keep BC + // fallback to TerminateProcess() + if(sig_no == SIGUSR1) { + if (GenerateConsoleCtrlEvent(CTRL_C_EVENT, proc->child)) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } + } else if(sig_no == SIGUSR1) { + if (GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, proc->child)) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } } else { - RETURN_FALSE; + if (TerminateProcess(proc->childHandle, 255)) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } } #else if (kill(proc->child, sig_no) == 0) { @@ -734,6 +750,11 @@ PHP_FUNCTION(proc_open) goto exit_fail; } + //alloc a new console for the child process to allow sending ctrl+c to this specific process and descendants + //the process group id required by GenerateConsoleCtrlEvent() is the same as process id returned by CreateProcessW() + //pi->dwProcessId + dwCreateFlags |= CREATE_NEW_CONSOLE; + if (bypass_shell) { newprocok = CreateProcessW(NULL, cmdw, &security, &security, TRUE, dwCreateFlags, envpw, cwdw, &si, &pi); } else {