nlopess Wed Feb 14 19:20:15 2007 UTC Modified files: /php-src/ext/standard proc_open.c /php-src/ext/standard/tests/general_functions bug39322.phpt proc_open02.phpt phpcredits.phpt Log: MFB http://cvs.php.net/viewvc.cgi/php-src/ext/standard/proc_open.c?r1=1.52&r2=1.53&diff_format=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.52 php-src/ext/standard/proc_open.c:1.53 --- php-src/ext/standard/proc_open.c:1.52 Tue Feb 13 19:56:42 2007 +++ php-src/ext/standard/proc_open.c Wed Feb 14 19:20:14 2007 @@ -15,7 +15,7 @@ | Author: Wez Furlong <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: proc_open.c,v 1.52 2007/02/13 19:56:42 nlopess Exp $ */ +/* $Id: proc_open.c,v 1.53 2007/02/14 19:20:14 nlopess Exp $ */ #if 0 && (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -253,7 +253,7 @@ } /* }}} */ -/* {{{ proto int proc_terminate(resource process [, long signal]) U +/* {{{ proto bool proc_terminate(resource process [, long signal]) U kill a process opened by proc_open */ PHP_FUNCTION(proc_terminate) { @@ -268,13 +268,18 @@ ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, &zproc, -1, "process", le_proc_open); #ifdef PHP_WIN32 - TerminateProcess(proc->childHandle, 255); + if (TerminateProcess(proc->childHandle, 255)) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } #else - kill(proc->child, sig_no); + if (kill(proc->child, sig_no) == 0) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } #endif - - zend_list_delete(Z_LVAL_P(zproc)); - RETURN_LONG(FG(pclose_ret)); } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/bug39322.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/general_functions/bug39322.phpt diff -u /dev/null php-src/ext/standard/tests/general_functions/bug39322.phpt:1.2 --- /dev/null Wed Feb 14 19:20:15 2007 +++ php-src/ext/standard/tests/general_functions/bug39322.phpt Wed Feb 14 19:20:15 2007 @@ -0,0 +1,44 @@ +--TEST-- +bug #39322: proc_terminate() loosing process resource +--SKIPIF-- +<?php +if (!is_executable('/bin/sleep')) echo 'skip sleep not found'; +?> +--FILE-- +<?php +$descriptors = array( + 0 => array('pipe', 'r'), + 1 => array('pipe', 'w'), + 2 => array('pipe', 'w')); + +$pipes = array(); + +$process = proc_open('/bin/sleep 120', $descriptors, $pipes); + +proc_terminate($process); +sleep(1); // wait a bit to let the process finish +var_dump(proc_get_status($process)); + +echo "Done!\n"; + +?> +--EXPECTF-- +array(8) { + ["command"]=> + string(14) "/bin/sleep 120" + ["pid"]=> + int(%d) + ["running"]=> + bool(false) + ["signaled"]=> + bool(true) + ["stopped"]=> + bool(false) + ["exitcode"]=> + int(-1) + ["termsig"]=> + int(15) + ["stopsig"]=> + int(0) +} +Done! http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/proc_open02.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/general_functions/proc_open02.phpt diff -u /dev/null php-src/ext/standard/tests/general_functions/proc_open02.phpt:1.2 --- /dev/null Wed Feb 14 19:20:15 2007 +++ php-src/ext/standard/tests/general_functions/proc_open02.phpt Wed Feb 14 19:20:15 2007 @@ -0,0 +1,70 @@ +--TEST-- +proc_open +--SKIPIF-- +<?php +if (!is_executable('/bin/sleep')) echo 'skip no sleep'; +if (!is_executable('/bin/nohup')) echo 'skip no nohup'; +?> +--FILE-- +<?php +$ds = array(array('pipe', 'r')); + +$cat = proc_open( + '/bin/nohup /bin/sleep 50', + $ds, + $pipes +); + +var_dump(proc_terminate($cat, 1)); // send a SIGHUP +sleep(1); +var_dump(proc_get_status($cat)); + +var_dump(proc_terminate($cat)); // now really quit it +sleep(1); +var_dump(proc_get_status($cat)); + +proc_close($cat); + +echo "Done!\n"; + +?> +--EXPECTF-- +bool(true) +array(8) { + ["command"]=> + string(24) "/bin/nohup /bin/sleep 50" + ["pid"]=> + int(%d) + ["running"]=> + bool(true) + ["signaled"]=> + bool(false) + ["stopped"]=> + bool(false) + ["exitcode"]=> + int(-1) + ["termsig"]=> + int(0) + ["stopsig"]=> + int(0) +} +bool(true) +array(8) { + ["command"]=> + string(24) "/bin/nohup /bin/sleep 50" + ["pid"]=> + int(%d) + ["running"]=> + bool(false) + ["signaled"]=> + bool(true) + ["stopped"]=> + bool(false) + ["exitcode"]=> + int(-1) + ["termsig"]=> + int(15) + ["stopsig"]=> + int(0) +} +Done! http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/phpcredits.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/standard/tests/general_functions/phpcredits.phpt diff -u php-src/ext/standard/tests/general_functions/phpcredits.phpt:1.2 php-src/ext/standard/tests/general_functions/phpcredits.phpt:1.3 --- php-src/ext/standard/tests/general_functions/phpcredits.phpt:1.2 Fri Nov 24 20:20:51 2006 +++ php-src/ext/standard/tests/general_functions/phpcredits.phpt Wed Feb 14 19:20:15 2007 @@ -22,7 +22,7 @@ Language Design & Concept %s -%wPHP %d Authors%w +%wPHP Authors%w %s %wSAPI Modules%w
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php