gschlossnagle Tue Oct 28 12:08:25 2003 EDT
Modified files:
/php-src/ext/pcntl config.m4 pcntl.c php_pcntl.h
Log:
Added pcntl_wait, a wraspper around wait()/wait3()
Index: php-src/ext/pcntl/config.m4
diff -u php-src/ext/pcntl/config.m4:1.9 php-src/ext/pcntl/config.m4:1.10
--- php-src/ext/pcntl/config.m4:1.9 Mon Feb 17 22:25:33 2003
+++ php-src/ext/pcntl/config.m4 Tue Oct 28 12:08:18 2003
@@ -1,5 +1,5 @@
dnl
-dnl $Id: config.m4,v 1.9 2003/02/18 03:25:33 sniper Exp $
+dnl $Id: config.m4,v 1.10 2003/10/28 17:08:18 gschlossnagle Exp $
dnl
dnl Process Control (pcntl) extentsion --EXPERIMENTAL--
@@ -13,7 +13,7 @@
AC_CHECK_FUNCS(fork, [ AC_DEFINE(HAVE_FORK,1,[ ]) ], [ AC_MSG_ERROR(pcntl: fork()
not supported by this platform) ])
AC_CHECK_FUNCS(waitpid, [ AC_DEFINE(HAVE_WAITPID,1,[ ]) ], [ AC_MSG_ERROR(pcntl:
fork() not supported by this platform) ])
AC_CHECK_FUNCS(sigaction, [ AC_DEFINE(HAVE_SIGACTION,1,[ ]) ], [
AC_MSG_ERROR(pcntl: sigaction() not supported by this platform) ])
- AC_CHECK_FUNCS(getpriority setpriority)
+ AC_CHECK_FUNCS(getpriority setpriority wait3)
PHP_NEW_EXTENSION(pcntl, pcntl.c php_signal.c, $ext_shared, cli)
fi
Index: php-src/ext/pcntl/pcntl.c
diff -u php-src/ext/pcntl/pcntl.c:1.39 php-src/ext/pcntl/pcntl.c:1.40
--- php-src/ext/pcntl/pcntl.c:1.39 Sun Aug 31 10:35:10 2003
+++ php-src/ext/pcntl/pcntl.c Tue Oct 28 12:08:18 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pcntl.c,v 1.39 2003/08/31 14:35:10 helly Exp $ */
+/* $Id: pcntl.c,v 1.40 2003/10/28 17:08:18 gschlossnagle Exp $ */
#define PCNTL_DEBUG 0
@@ -36,7 +36,7 @@
#include "ext/standard/info.h"
#include "php_pcntl.h"
-#if HAVE_GETPRIORITY || HAVE_SETPRIORITY
+#if HAVE_GETPRIORITY || HAVE_SETPRIORITY || HAVE_WAIT3
#include <sys/time.h>
#include <sys/resource.h>
#endif
@@ -46,6 +46,7 @@
function_entry pcntl_functions[] = {
PHP_FE(pcntl_fork, NULL)
PHP_FE(pcntl_waitpid, second_arg_force_ref)
+ PHP_FE(pcntl_wait, first_arg_force_ref)
PHP_FE(pcntl_signal, NULL)
PHP_FE(pcntl_wifexited, NULL)
PHP_FE(pcntl_wifstopped, NULL)
@@ -243,6 +244,37 @@
child_id = waitpid((pid_t) pid, &status, options);
+ Z_LVAL_P(z_status) = status;
+
+ RETURN_LONG((long) child_id);
+}
+/* }}} */
+
+/* {{{ proto int pcntl_wait(int &status)
+ Waits on or returns the status of a forked child as defined by the waitpid()
system call */
+PHP_FUNCTION(pcntl_wait)
+{
+ long pid, options = 0;
+ zval *z_status = NULL;
+ int status;
+ pid_t child_id;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &z_status,
&options) == FAILURE)
+ return;
+
+ convert_to_long_ex(&z_status);
+
+ status = Z_LVAL_P(z_status);
+#ifdef HAVE_WAIT3
+ if(options) {
+ child_id = wait3(&status, options, NULL);
+ }
+ else {
+ child_id = wait(&status);
+ }
+#else
+ child_id = wait(&status);
+#endif
Z_LVAL_P(z_status) = status;
RETURN_LONG((long) child_id);
Index: php-src/ext/pcntl/php_pcntl.h
diff -u php-src/ext/pcntl/php_pcntl.h:1.15 php-src/ext/pcntl/php_pcntl.h:1.16
--- php-src/ext/pcntl/php_pcntl.h:1.15 Tue Jun 10 16:03:34 2003
+++ php-src/ext/pcntl/php_pcntl.h Tue Oct 28 12:08:18 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_pcntl.h,v 1.15 2003/06/10 20:03:34 imajes Exp $ */
+/* $Id: php_pcntl.h,v 1.16 2003/10/28 17:08:18 gschlossnagle Exp $ */
#ifndef PHP_PCNTL_H
#define PHP_PCNTL_H
@@ -42,6 +42,7 @@
PHP_FUNCTION(pcntl_alarm);
PHP_FUNCTION(pcntl_fork);
PHP_FUNCTION(pcntl_waitpid);
+PHP_FUNCTION(pcntl_wait);
PHP_FUNCTION(pcntl_wifexited);
PHP_FUNCTION(pcntl_wifstopped);
PHP_FUNCTION(pcntl_wifsignaled);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php