summaryrefslogtreecommitdiff
path: root/ext/pcntl
diff options
context:
space:
mode:
Diffstat (limited to 'ext/pcntl')
-rw-r--r--ext/pcntl/CREDITS2
-rwxr-xr-xext/pcntl/pcntl.c49
-rw-r--r--ext/pcntl/php_signal.h7
-rw-r--r--ext/pcntl/tests/002.phpt35
4 files changed, 35 insertions, 58 deletions
diff --git a/ext/pcntl/CREDITS b/ext/pcntl/CREDITS
index cdf51d6592..1d629d7adf 100644
--- a/ext/pcntl/CREDITS
+++ b/ext/pcntl/CREDITS
@@ -1,2 +1,2 @@
pcntl
-Jason Greene, Arnaud Le Blanc
+Jason Greene
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c
index 2840925f0a..fbe79baf00 100755
--- a/ext/pcntl/pcntl.c
+++ b/ext/pcntl/pcntl.c
@@ -48,37 +48,43 @@ ZEND_DECLARE_MODULE_GLOBALS(pcntl)
static PHP_GINIT_FUNCTION(pcntl);
/* {{{ arginfo */
+static
ZEND_BEGIN_ARG_INFO(arginfo_pcntl_void, 0)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_pcntl_waitpid, 0, 0, 2)
ZEND_ARG_INFO(0, pid)
ZEND_ARG_INFO(1, status)
ZEND_ARG_INFO(0, options)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_pcntl_wait, 0, 0, 1)
ZEND_ARG_INFO(1, status)
ZEND_ARG_INFO(0, options)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_pcntl_signal, 0, 0, 2)
ZEND_ARG_INFO(0, signo)
ZEND_ARG_INFO(0, handler)
ZEND_ARG_INFO(0, restart_syscalls)
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_ARG_INFO(1, oldset)
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)
@@ -86,41 +92,50 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_pcntl_sigtimedwait, 0, 0, 1)
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()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_pcntl_wifstopped, 0, 0, 1)
ZEND_ARG_INFO(0, status)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_pcntl_wifsignaled, 0, 0, 1)
ZEND_ARG_INFO(0, status)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_pcntl_wifexitstatus, 0, 0, 1)
ZEND_ARG_INFO(0, status)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_pcntl_wtermsig, 0, 0, 1)
ZEND_ARG_INFO(0, status)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_pcntl_wstopsig, 0, 0, 1)
ZEND_ARG_INFO(0, status)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_pcntl_exec, 0, 0, 1)
ZEND_ARG_INFO(0, path)
ZEND_ARG_INFO(0, args)
ZEND_ARG_INFO(0, envs)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_pcntl_alarm, 0, 0, 1)
ZEND_ARG_INFO(0, seconds)
ZEND_END_ARG_INFO()
#ifdef HAVE_GETPRIORITY
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_pcntl_getpriority, 0, 0, 0)
ZEND_ARG_INFO(0, pid)
ZEND_ARG_INFO(0, process_identifier)
@@ -128,6 +143,7 @@ ZEND_END_ARG_INFO()
#endif
#ifdef HAVE_SETPRIORITY
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_pcntl_setpriority, 0, 0, 1)
ZEND_ARG_INFO(0, priority)
ZEND_ARG_INFO(0, pid)
@@ -586,7 +602,7 @@ PHP_FUNCTION(pcntl_wstopsig)
Executes specified program in current process space as defined by exec(2) */
PHP_FUNCTION(pcntl_exec)
{
- zval *args = NULL, *envs = NULL;
+ zval *args, *envs;
zval **element;
HashTable *args_hash, *envs_hash;
int argc = 0, argi = 0;
@@ -744,20 +760,20 @@ PHP_FUNCTION(pcntl_signal_dispatch)
/* }}} */
#ifdef HAVE_SIGPROCMASK
-/* {{{ proto bool pcntl_sigprocmask(int how, array set[, array &oldset])
+/* {{{ proto bool pcntl_sigprocmask(int how, array set)
Examine and change blocked signals */
PHP_FUNCTION(pcntl_sigprocmask)
{
long how, signo;
- zval *user_set, *user_oldset = NULL, **user_signo;
- sigset_t set, oldset;
+ zval *user_set, **user_signo;
+ sigset_t set;
HashPosition pos;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la|z", &how, &user_set, &user_oldset) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la", &how, &user_set) == FAILURE) {
return;
}
- if (sigemptyset(&set) != 0 || sigemptyset(&oldset) != 0) {
+ if (sigemptyset(&set) != 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
RETURN_FALSE;
}
@@ -777,26 +793,11 @@ PHP_FUNCTION(pcntl_sigprocmask)
zend_hash_move_forward_ex(Z_ARRVAL_P(user_set), &pos);
}
- if (sigprocmask(how, &set, &oldset) != 0) {
+ if (sigprocmask(how, &set, NULL) != 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
RETURN_FALSE;
}
- if (user_oldset != NULL) {
- if (Z_TYPE_P(user_oldset) != IS_ARRAY) {
- zval_dtor(user_oldset);
- array_init(user_oldset);
- } else {
- zend_hash_clean(Z_ARRVAL_P(user_oldset));
- }
- for (signo = 1; signo < MAX(NSIG-1, SIGRTMAX); ++signo) {
- if (sigismember(&oldset, signo) != 1) {
- continue;
- }
- add_next_index_long(user_oldset, signo);
- }
- }
-
RETURN_TRUE;
}
/* }}} */
@@ -858,8 +859,6 @@ static void pcntl_sigwaitinfo(INTERNAL_FUNCTION_PARAMETERS, int timedwait) /* {{
if (Z_TYPE_P(user_siginfo) != IS_ARRAY) {
zval_dtor(user_siginfo);
array_init(user_siginfo);
- } else {
- zend_hash_clean(Z_ARRVAL_P(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);
diff --git a/ext/pcntl/php_signal.h b/ext/pcntl/php_signal.h
index cd1d547790..ed2e769dd7 100644
--- a/ext/pcntl/php_signal.h
+++ b/ext/pcntl/php_signal.h
@@ -22,13 +22,6 @@
#ifndef PHP_SIGNAL_H
#define PHP_SIGNAL_H
-#ifndef NSIG
-# define NSIG 32
-#endif
-#ifndef SIGRTMAX
-# define SIGRTMAX 64
-#endif
-
typedef void Sigfunc(int);
Sigfunc *php_signal(int signo, Sigfunc *func, int restart);
diff --git a/ext/pcntl/tests/002.phpt b/ext/pcntl/tests/002.phpt
index ac0ca9f75a..9ea7cf9bb1 100644
--- a/ext/pcntl/tests/002.phpt
+++ b/ext/pcntl/tests/002.phpt
@@ -4,7 +4,6 @@ pcntl: pcntl_sigprocmask(), pcntl_sigwaitinfo(), pcntl_sigtimedwait()
<?php
if (!extension_loaded('pcntl')) die('skip pcntl extension not available');
elseif (!extension_loaded('posix')) die('skip posix extension not available');
- elseif (!function_exists('pcntl_sigwaitinfo') or !function_exists('pcntl_sigtimedwait')) die('skip required functionality is not available');
?>
--FILE--
<?php
@@ -14,11 +13,6 @@ if ($pid == -1) {
die('failed');
} else if ($pid) {
pcntl_sigprocmask(SIG_BLOCK, array(SIGCHLD,(string)SIGTERM));
- $oldset = array();
- pcntl_sigprocmask(SIG_BLOCK, array(), $oldset);
- var_dump(in_array(SIGCHLD, $oldset));
- var_dump(in_array(SIGTERM, $oldset));
-
posix_kill(posix_getpid(), SIGTERM);
$signo = pcntl_sigwaitinfo(array(SIGTERM), $siginfo);
echo "signo == SIGTERM\n";
@@ -45,19 +39,8 @@ if ($pid == -1) {
var_dump($siginfo['pid'] === $pid);
pcntl_waitpid($pid, $status);
- set_error_handler(function($errno, $errstr) { echo "Error triggered\n"; }, E_WARNING);
-
echo "sigprocmask with invalid arguments\n";
-
- /* Valgrind expectedly complains about this:
- * "sigprocmask: unknown 'how' field 2147483647"
- * Skip */
- if (getenv("USE_ZEND_ALLOC") !== '0') {
- var_dump(pcntl_sigprocmask(PHP_INT_MAX, array(SIGTERM)));
- } else {
- echo "Error triggered\n";
- echo "bool(false)\n";
- }
+ var_dump(pcntl_sigprocmask(PHP_INT_MAX, array(SIGTERM)));
var_dump(pcntl_sigprocmask(SIG_SETMASK, array(0)));
echo "sigwaitinfo with invalid arguments\n";
@@ -67,14 +50,12 @@ if ($pid == -1) {
var_dump(pcntl_sigtimedwait(array(SIGTERM), $signo, PHP_INT_MAX, PHP_INT_MAX));
} else {
$siginfo = NULL;
- pcntl_sigtimedwait(array(SIGINT), $siginfo, PHP_INT_MAX, 999999999);
+ pcntl_sigtimedwait(array(SIGTERM), $siginfo, PHP_INT_MAX, 999999999);
exit;
}
?>
--EXPECTF--
-bool(true)
-bool(true)
signo == SIGTERM
bool(true)
code === SI_USER || SI_NOINFO
@@ -90,13 +71,17 @@ bool(true)
signo === pid
bool(true)
sigprocmask with invalid arguments
-Error triggered
+
+Warning: pcntl_sigprocmask(): Invalid argument in %s on line %d
bool(false)
-Error triggered
+
+Warning: pcntl_sigprocmask(): Invalid argument in %s on line %d
bool(false)
sigwaitinfo with invalid arguments
-Error triggered
+
+Warning: pcntl_sigwaitinfo(): Invalid argument in %s on line %d
bool(false)
sigtimedwait with invalid arguments
-Error triggered
+
+Warning: pcntl_sigtimedwait(): Invalid argument in %s on line %d
int(-1)