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
#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
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)
}
/* }}} */
+/* {{{ 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);
+}
+/* }}} */
+
/* {{{ proto bool pcntl_wifexited(int status)
Returns true if the child status code represents a successful exit */
PHP_FUNCTION(pcntl_wifexited)
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);