From c3c24054e8e9546006fe406cc09ad2e16a73a528 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 15 Feb 2003 17:18:57 +0000 Subject: Add proc_terminate() function to forcibly kill off a process created with proc_open(). --- ext/standard/proc_open.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'ext/standard/proc_open.c') 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) -- cgit v1.2.1