diff options
author | Wez Furlong <wez@php.net> | 2003-02-15 17:18:57 +0000 |
---|---|---|
committer | Wez Furlong <wez@php.net> | 2003-02-15 17:18:57 +0000 |
commit | c3c24054e8e9546006fe406cc09ad2e16a73a528 (patch) | |
tree | 146310f513f5577a484e7c0f61cd29efa06fe95b | |
parent | 8a07cc45cfb3cfad38a65f027e59b2e1d02f091e (diff) | |
download | php-git-c3c24054e8e9546006fe406cc09ad2e16a73a528.tar.gz |
Add proc_terminate() function to forcibly kill off a process created
with proc_open().
-rw-r--r-- | ext/standard/basic_functions.c | 1 | ||||
-rw-r--r-- | ext/standard/exec.h | 1 | ||||
-rw-r--r-- | ext/standard/proc_open.c | 26 |
3 files changed, 28 insertions, 0 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index d82913aed0..84192e0a25 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -419,6 +419,7 @@ function_entry basic_functions[] = { #ifdef PHP_CAN_SUPPORT_PROC_OPEN PHP_FE(proc_open, third_arg_force_ref) PHP_FE(proc_close, NULL) + PHP_FE(proc_terminate, NULL) PHP_FE(proc_get_status, NULL) #endif diff --git a/ext/standard/exec.h b/ext/standard/exec.h index cdfe8a54ed..796701317f 100644 --- a/ext/standard/exec.h +++ b/ext/standard/exec.h @@ -30,6 +30,7 @@ PHP_FUNCTION(shell_exec); PHP_FUNCTION(proc_open); PHP_FUNCTION(proc_get_status); PHP_FUNCTION(proc_close); +PHP_FUNCTION(proc_terminate); PHP_MINIT_FUNCTION(proc_open); char *php_escape_shell_cmd(char *); diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index 7cca8a5ac4..993e876127 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -174,6 +174,32 @@ PHP_MINIT_FUNCTION(proc_open) return SUCCESS; } + +/* {{{ proto int proc_terminate(resource process) + kill a process opened by proc_open */ +PHP_FUNCTION(proc_terminate) +{ + zval *zproc; + struct php_process_handle *proc; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zproc) == FAILURE) { + RETURN_FALSE; + } + + ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, &zproc, -1, "process", le_proc_open); + +#ifdef PHP_WIN32 + TerminateProcess(proc->child, 255); +#else + kill(proc->child, SIGTERM); +#endif + + zend_list_delete(Z_LVAL_P(zproc)); + RETURN_LONG(FG(pclose_ret)); +} +/* }}} */ + + /* {{{ proto int proc_close(resource process) close a process opened by proc_open */ PHP_FUNCTION(proc_close) |