lbarnaud Tue Jul 29 16:59:10 2008 UTC
Added files: (Branch: PHP_5_3)
/php-src/ext/pcntl/tests 002.phpt
Modified files:
/php-src NEWS
/php-src/ext/pcntl config.m4 pcntl.c php_pcntl.h
Log:
MFH: Added pcntl_sigwaitinfo(), pcntl_sigtimedwait() and pcntl_sigprocmask()
[DOC] pcntl_sigprocmask() allows to block signals. pcntl_sigwaitinfo()
allows to fetch blocked signals or signals delivered while pcntl_sigwaitinfo()
is running. pcntl_sigtimedwait() is pcntl_sigwaitinfo() with a timeout.
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.230&r2=1.2027.2.547.2.965.2.231&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.965.2.230
php-src/NEWS:1.2027.2.547.2.965.2.231
--- php-src/NEWS:1.2027.2.547.2.965.2.230 Mon Jul 28 19:08:02 2008
+++ php-src/NEWS Tue Jul 29 16:59:10 2008
@@ -210,6 +210,12 @@
DateInterval on each iteration, up to an end date or limited by maximum
number of occurences.
+- Improved pcntl extension: (Arnaud)
+ . Added pcntl_signal_dispatch()
+ . Added pcntl_sigprocmask()
+ . Added pcntl_sigwaitinfo()
+ . Added pcntl_sigtimedwait()
+
- Added hash_copy() function. (Tony)
- Added sha224 hash algorithm to the hash extension. (Scott)
- Added ReflectionProperty::setAccessible() method that allows non-public
http://cvs.php.net/viewvc.cgi/php-src/ext/pcntl/config.m4?r1=1.10&r2=1.10.8.1&diff_format=u
Index: php-src/ext/pcntl/config.m4
diff -u php-src/ext/pcntl/config.m4:1.10 php-src/ext/pcntl/config.m4:1.10.8.1
--- php-src/ext/pcntl/config.m4:1.10 Tue Oct 28 17:08:18 2003
+++ php-src/ext/pcntl/config.m4 Tue Jul 29 16:59:10 2008
@@ -1,5 +1,5 @@
dnl
-dnl $Id: config.m4,v 1.10 2003/10/28 17:08:18 gschlossnagle Exp $
+dnl $Id: config.m4,v 1.10.8.1 2008/07/29 16:59:10 lbarnaud 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 wait3)
+ AC_CHECK_FUNCS(getpriority setpriority wait3 sigprocmask sigwaitinfo
sigtimedwait)
PHP_NEW_EXTENSION(pcntl, pcntl.c php_signal.c, $ext_shared, cli)
fi
http://cvs.php.net/viewvc.cgi/php-src/ext/pcntl/pcntl.c?r1=1.48.2.2.2.4.2.6&r2=1.48.2.2.2.4.2.7&diff_format=u
Index: php-src/ext/pcntl/pcntl.c
diff -u php-src/ext/pcntl/pcntl.c:1.48.2.2.2.4.2.6
php-src/ext/pcntl/pcntl.c:1.48.2.2.2.4.2.7
--- php-src/ext/pcntl/pcntl.c:1.48.2.2.2.4.2.6 Tue Jul 29 16:46:11 2008
+++ php-src/ext/pcntl/pcntl.c Tue Jul 29 16:59:10 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pcntl.c,v 1.48.2.2.2.4.2.6 2008/07/29 16:46:11 lbarnaud Exp $ */
+/* $Id: pcntl.c,v 1.48.2.2.2.4.2.7 2008/07/29 16:59:10 lbarnaud Exp $ */
#define PCNTL_DEBUG 0
@@ -70,6 +70,26 @@
ZEND_END_ARG_INFO()
static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pcntl_sigprocmask, 0, 0, 2)
+ ZEND_ARG_INFO(0, how)
+ ZEND_ARG_INFO(0, set)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pcntl_sigwaitinfo, 0, 0, 1)
+ ZEND_ARG_INFO(0, set)
+ ZEND_ARG_INFO(1, info)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pcntl_sigtimedwait, 0, 0, 1)
+ ZEND_ARG_INFO(0, set)
+ ZEND_ARG_INFO(1, info)
+ ZEND_ARG_INFO(0, seconds)
+ ZEND_ARG_INFO(0, nanoseconds)
+ZEND_END_ARG_INFO()
+
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_pcntl_wifexited, 0, 0, 1)
ZEND_ARG_INFO(0, status)
ZEND_END_ARG_INFO()
@@ -149,6 +169,13 @@
#ifdef HAVE_SETPRIORITY
PHP_FE(pcntl_setpriority, arginfo_pcntl_setpriority)
#endif
+#ifdef HAVE_SIGPROCMASK
+ PHP_FE(pcntl_sigprocmask, arginfo_pcntl_sigprocmask)
+#endif
+#if HAVE_SIGWAITINFO && HAVE_SIGTIMEDWAIT
+ PHP_FE(pcntl_sigwaitinfo, arginfo_pcntl_sigwaitinfo)
+ PHP_FE(pcntl_sigtimedwait, arginfo_pcntl_sigtimedwait)
+#endif
{NULL, NULL, NULL}
};
@@ -246,6 +273,81 @@
REGISTER_LONG_CONSTANT("PRIO_USER", PRIO_USER, CONST_CS |
CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PRIO_PROCESS", PRIO_PROCESS, CONST_CS |
CONST_PERSISTENT);
#endif
+
+ /* {{{ "how" argument for sigprocmask */
+#ifdef HAVE_SIGPROCMASK
+ REGISTER_LONG_CONSTANT("SIG_BLOCK", SIG_BLOCK, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIG_UNBLOCK", SIG_BLOCK, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIG_SETMASK", SIG_BLOCK, CONST_CS |
CONST_PERSISTENT);
+#endif
+ /* }}} */
+
+ /* {{{ si_code */
+#if HAVE_SIGWAITINFO && HAVE_SIGTIMEDWAIT
+ REGISTER_LONG_CONSTANT("SI_USER", SI_USER, CONST_CS |
CONST_PERSISTENT);
+#ifdef SI_NOINFO
+ REGISTER_LONG_CONSTANT("SI_NOINFO", SI_NOINFO, CONST_CS |
CONST_PERSISTENT);
+#endif
+#ifdef SI_KERNEL
+ REGISTER_LONG_CONSTANT("SI_KERNEL", SI_KERNEL, CONST_CS |
CONST_PERSISTENT);
+#endif
+ REGISTER_LONG_CONSTANT("SI_QUEUE", SI_QUEUE, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SI_TIMER", SI_TIMER, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SI_MESGQ", SI_MESGQ, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SI_ASYNCIO", SI_ASYNCIO, CONST_CS |
CONST_PERSISTENT);
+#ifdef SI_SIGIO
+ REGISTER_LONG_CONSTANT("SI_SIGIO", SI_SIGIO, CONST_CS |
CONST_PERSISTENT);
+#endif
+#ifdef SI_TKILL
+ REGISTER_LONG_CONSTANT("SI_TKILL", SI_TKILL, CONST_CS |
CONST_PERSISTENT);
+#endif
+
+ /* si_code for SIGCHILD */
+ REGISTER_LONG_CONSTANT("CLD_EXITED", CLD_EXITED, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("CLD_KILLED", CLD_KILLED, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("CLD_DUMPED", CLD_DUMPED, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("CLD_TRAPPED", CLD_TRAPPED, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("CLD_STOPPED", CLD_STOPPED, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("CLD_CONTINUED", CLD_CONTINUED, CONST_CS |
CONST_PERSISTENT);
+
+ /* si_code for SIGTRAP */
+ REGISTER_LONG_CONSTANT("TRAP_BRKPT", TRAP_BRKPT, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("TRAP_TRACE", TRAP_TRACE, CONST_CS |
CONST_PERSISTENT);
+
+ /* si_code for SIGPOLL */
+ REGISTER_LONG_CONSTANT("POLL_IN", POLL_IN, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("POLL_OUT", POLL_OUT, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("POLL_MSG", POLL_MSG, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("POLL_ERR", POLL_ERR, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("POLL_PRI", POLL_PRI, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("POLL_HUP", POLL_HUP, CONST_CS |
CONST_PERSISTENT);
+
+ REGISTER_LONG_CONSTANT("ILL_ILLOPC", ILL_ILLOPC, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("ILL_ILLOPN", ILL_ILLOPN, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("ILL_ILLADR", ILL_ILLADR, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("ILL_ILLTRP", ILL_ILLTRP, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("ILL_PRVOPC", ILL_PRVOPC, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("ILL_PRVREG", ILL_PRVREG, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("ILL_COPROC", ILL_COPROC, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("ILL_BADSTK", ILL_BADSTK, CONST_CS |
CONST_PERSISTENT);
+
+ REGISTER_LONG_CONSTANT("FPE_INTDIV", FPE_INTDIV, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("FPE_INTOVF", FPE_INTOVF, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("FPE_FLTDIV", FPE_FLTDIV, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("FPE_FLTOVF", FPE_FLTOVF, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("FPE_FLTUND", FPE_FLTINV, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("FPE_FLTRES", FPE_FLTRES, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("FPE_FLTINV", FPE_FLTINV, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("FPE_FLTSUB", FPE_FLTSUB, CONST_CS |
CONST_PERSISTENT);
+
+ REGISTER_LONG_CONSTANT("SEGV_MAPERR", SEGV_MAPERR, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SEGV_ACCERR", SEGV_ACCERR, CONST_CS |
CONST_PERSISTENT);
+
+ REGISTER_LONG_CONSTANT("BUS_ADRALN", BUS_ADRALN, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("BUS_ADRERR", BUS_ADRERR, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("BUS_OBJERR", BUS_OBJERR, CONST_CS |
CONST_PERSISTENT);
+#endif
+ /* }}} */
}
static PHP_GINIT_FUNCTION(pcntl)
@@ -654,6 +756,161 @@
}
/* }}} */
+#ifdef HAVE_SIGPROCMASK
+/* {{{ proto bool pcntl_sigprocmask(int how, array set)
+ Examine and change blocked signals */
+PHP_FUNCTION(pcntl_sigprocmask)
+{
+ long how, signo;
+ zval *user_set, **user_signo;
+ sigset_t set;
+ HashPosition pos;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la", &how,
&user_set) == FAILURE) {
+ return;
+ }
+
+ if (sigemptyset(&set) != 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s",
strerror(errno));
+ RETURN_FALSE;
+ }
+
+ zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(user_set), &pos);
+ while (zend_hash_get_current_data_ex(Z_ARRVAL_P(user_set), (void
**)&user_signo, &pos) == SUCCESS)
+ {
+ if (Z_TYPE_PP(user_signo) != IS_LONG) {
+ SEPARATE_ZVAL(user_signo);
+ convert_to_long_ex(user_signo);
+ }
+ signo = Z_LVAL_PP(user_signo);
+ if (sigaddset(&set, signo) != 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s",
strerror(errno));
+ RETURN_FALSE;
+ }
+ zend_hash_move_forward_ex(Z_ARRVAL_P(user_set), &pos);
+ }
+
+ if (sigprocmask(how, &set, NULL) != 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s",
strerror(errno));
+ RETURN_FALSE;
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+#endif
+
+#if HAVE_SIGWAITINFO && HAVE_SIGTIMEDWAIT
+static void pcntl_sigwaitinfo(INTERNAL_FUNCTION_PARAMETERS, int timedwait) /*
{{{ */
+{
+ zval *user_set, **user_signo, *user_siginfo = NULL;
+ long tv_sec = 0, tv_nsec = 0;
+ sigset_t set;
+ HashPosition pos;
+ int signo;
+ siginfo_t siginfo;
+ struct timespec timeout;
+
+ if (timedwait) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|zll",
&user_set, &user_siginfo, &tv_sec, &tv_nsec) == FAILURE) {
+ return;
+ }
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|z",
&user_set, &user_siginfo) == FAILURE) {
+ return;
+ }
+ }
+
+ if (sigemptyset(&set) != 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s",
strerror(errno));
+ RETURN_FALSE;
+ }
+
+ zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(user_set), &pos);
+ while (zend_hash_get_current_data_ex(Z_ARRVAL_P(user_set), (void
**)&user_signo, &pos) == SUCCESS)
+ {
+ if (Z_TYPE_PP(user_signo) != IS_LONG) {
+ SEPARATE_ZVAL(user_signo);
+ convert_to_long_ex(user_signo);
+ }
+ signo = Z_LVAL_PP(user_signo);
+ if (sigaddset(&set, signo) != 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s",
strerror(errno));
+ RETURN_FALSE;
+ }
+ zend_hash_move_forward_ex(Z_ARRVAL_P(user_set), &pos);
+ }
+
+ if (timedwait) {
+ timeout.tv_sec = (time_t) tv_sec;
+ timeout.tv_nsec = tv_nsec;
+ signo = sigtimedwait(&set, &siginfo, &timeout);
+ } else {
+ signo = sigwaitinfo(&set, &siginfo);
+ }
+ if (signo == -1 && errno != EAGAIN) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s",
strerror(errno));
+ }
+
+ if (signo > 0 && user_siginfo) {
+ if (Z_TYPE_P(user_siginfo) != IS_ARRAY) {
+ zval_dtor(user_siginfo);
+ array_init(user_siginfo);
+ }
+ add_assoc_long_ex(user_siginfo, "signo", sizeof("signo"),
siginfo.si_signo);
+ add_assoc_long_ex(user_siginfo, "errno", sizeof("errno"),
siginfo.si_errno);
+ add_assoc_long_ex(user_siginfo, "code", sizeof("code"),
siginfo.si_code);
+ switch(signo) {
+#ifdef SIGCHLD
+ case SIGCHLD:
+ add_assoc_long_ex(user_siginfo, "status",
sizeof("status"), siginfo.si_status);
+#ifdef si_utime
+ add_assoc_double_ex(user_siginfo, "utime",
sizeof("utime"), siginfo.si_utime);
+#endif
+#ifdef si_stime
+ add_assoc_double_ex(user_siginfo, "stime",
sizeof("stime"), siginfo.si_stime);
+#endif
+ add_assoc_long_ex(user_siginfo, "pid",
sizeof("pid"), siginfo.si_pid);
+ add_assoc_long_ex(user_siginfo, "uid",
sizeof("uid"), siginfo.si_uid);
+ break;
+#endif
+ case SIGILL:
+ case SIGFPE:
+ case SIGSEGV:
+ case SIGBUS:
+ add_assoc_double_ex(user_siginfo, "addr",
sizeof("addr"), (long)siginfo.si_addr);
+ break;
+#ifdef SIGPOLL
+ case SIGPOLL:
+ add_assoc_long_ex(user_siginfo, "band",
sizeof("band"), siginfo.si_band);
+ add_assoc_long_ex(user_siginfo, "fd",
sizeof("fd"), siginfo.si_fd);
+ break;
+#endif
+ EMPTY_SWITCH_DEFAULT_CASE();
+ }
+ }
+
+ RETURN_LONG(signo);
+}
+/* }}} */
+
+/* {{{ proto int sigwaitinfo(array set[, array &siginfo])
+ Synchronously wait for queued signals */
+PHP_FUNCTION(pcntl_sigwaitinfo)
+{
+ pcntl_sigwaitinfo(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
+}
+/* }}} */
+
+/* {{{ proto int sigtimedwait(array set[, array &siginfo[, int seconds[, int
nanoseconds]]])
+ Wait for queued signals */
+PHP_FUNCTION(pcntl_sigtimedwait)
+{
+ pcntl_sigwaitinfo(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
+}
+/* }}} */
+#endif
+
#ifdef HAVE_GETPRIORITY
/* {{{ proto int pcntl_getpriority([int pid [, int process_identifier]])
Get the priority of any process */
http://cvs.php.net/viewvc.cgi/php-src/ext/pcntl/php_pcntl.h?r1=1.20.2.1.2.1.2.3&r2=1.20.2.1.2.1.2.4&diff_format=u
Index: php-src/ext/pcntl/php_pcntl.h
diff -u php-src/ext/pcntl/php_pcntl.h:1.20.2.1.2.1.2.3
php-src/ext/pcntl/php_pcntl.h:1.20.2.1.2.1.2.4
--- php-src/ext/pcntl/php_pcntl.h:1.20.2.1.2.1.2.3 Tue Jul 29 16:46:11 2008
+++ php-src/ext/pcntl/php_pcntl.h Tue Jul 29 16:59:10 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_pcntl.h,v 1.20.2.1.2.1.2.3 2008/07/29 16:46:11 lbarnaud Exp $ */
+/* $Id: php_pcntl.h,v 1.20.2.1.2.1.2.4 2008/07/29 16:59:10 lbarnaud Exp $ */
#ifndef PHP_PCNTL_H
#define PHP_PCNTL_H
@@ -45,6 +45,13 @@
PHP_FUNCTION(pcntl_wstopsig);
PHP_FUNCTION(pcntl_signal);
PHP_FUNCTION(pcntl_signal_dispatch);
+#ifdef HAVE_SIGPROCMASK
+PHP_FUNCTION(pcntl_sigprocmask);
+#endif
+#if HAVE_SIGWAITINFO && HAVE_SIGTIMEDWAIT
+PHP_FUNCTION(pcntl_sigwaitinfo);
+PHP_FUNCTION(pcntl_sigtimedwait);
+#endif
PHP_FUNCTION(pcntl_exec);
#ifdef HAVE_GETPRIORITY
PHP_FUNCTION(pcntl_getpriority);
http://cvs.php.net/viewvc.cgi/php-src/ext/pcntl/tests/002.phpt?view=markup&rev=1.1
Index: php-src/ext/pcntl/tests/002.phpt
+++ php-src/ext/pcntl/tests/002.phpt
--TEST--
pcntl: pcntl_sigprocmask(), pcntl_sigwaitinfo(), pcntl_sigtimedwait()
--SKIPIF--
<?php
if (!extension_loaded('pcntl')) die('skip pcntl extension not available');
if (!extension_loaded('posix')) die('skip posix extension not available');
?>
--FILE--
<?php
$pid = pcntl_fork();
if ($pid == -1) {
die('failed');
} else if ($pid) {
pcntl_sigprocmask(SIG_BLOCK, array(SIGCHLD,(string)SIGTERM));
posix_kill(posix_getpid(), SIGTERM);
$signo = pcntl_sigwaitinfo(array(SIGTERM), $siginfo);
echo "signo == SIGTERM\n";
var_dump($signo === SIGTERM && $signo === $siginfo['signo']);
echo "code === SI_USER || SI_NOINFO\n";
if (defined('SI_NOINFO')) {
var_dump(($siginfo['code'] === SI_USER) || ($siginfo['code']
=== SI_NOINFO));
} else {
var_dump($siginfo['code'] === SI_USER);
}
pcntl_signal(SIGCHLD, function($signo){});
posix_kill($pid, SIGTERM);
$signo = pcntl_sigwaitinfo(array((string)SIGCHLD), $siginfo);
echo "signo == SIGCHLD\n";
var_dump($signo === SIGCHLD && $signo === $siginfo['signo']);
echo "code === CLD_KILLED\n";
var_dump($siginfo['code'] === CLD_KILLED);
echo "signo === SIGCHLD\n";
var_dump($siginfo['signo'] === SIGCHLD);
echo "signo === uid\n";
var_dump($siginfo['uid'] === posix_getuid());
echo "signo === pid\n";
var_dump($siginfo['pid'] === $pid);
pcntl_waitpid($pid, $status);
echo "sigprocmask with invalid arguments\n";
var_dump(pcntl_sigprocmask(PHP_INT_MAX, array(SIGTERM)));
var_dump(pcntl_sigprocmask(SIG_SETMASK, array(0)));
echo "sigwaitinfo with invalid arguments\n";
var_dump(pcntl_sigwaitinfo(array(0)));
echo "sigtimedwait with invalid arguments\n";
var_dump(pcntl_sigtimedwait(array(SIGTERM), $signo, PHP_INT_MAX,
PHP_INT_MAX));
} else {
$siginfo = NULL;
pcntl_sigtimedwait(array(SIGTERM), $siginfo, PHP_INT_MAX, 999999999);
exit;
}
?>
--EXPECTF--
signo == SIGTERM
bool(true)
code === SI_USER || SI_NOINFO
bool(true)
signo == SIGCHLD
bool(true)
code === CLD_KILLED
bool(true)
signo === SIGCHLD
bool(true)
signo === uid
bool(true)
signo === pid
bool(true)
sigprocmask with invalid arguments
Warning: pcntl_sigprocmask(): Invalid argument in %s on line %d
bool(false)
Warning: pcntl_sigprocmask(): Invalid argument in %s on line %d
bool(false)
sigwaitinfo with invalid arguments
Warning: pcntl_sigwaitinfo(): Invalid argument in %s on line %d
bool(false)
sigtimedwait with invalid arguments
Warning: pcntl_sigtimedwait(): Invalid argument in %s on line %d
int(-1)
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php