summaryrefslogtreecommitdiff
path: root/ext/pcntl
diff options
context:
space:
mode:
Diffstat (limited to 'ext/pcntl')
-rw-r--r--ext/pcntl/pcntl.c26
-rw-r--r--ext/pcntl/pcntl.stub.php6
-rw-r--r--ext/pcntl/pcntl_arginfo.h6
3 files changed, 21 insertions, 17 deletions
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c
index 6f9fd8a182..6206342168 100644
--- a/ext/pcntl/pcntl.c
+++ b/ext/pcntl/pcntl.c
@@ -1196,17 +1196,18 @@ static void pcntl_siginfo_to_zval(int signo, siginfo_t *siginfo, zval *user_sigi
PHP_FUNCTION(pcntl_getpriority)
{
zend_long who = PRIO_PROCESS;
- zend_long pid = getpid();
+ zend_long pid;
+ zend_bool pid_is_null = 1;
int pri;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ll", &pid, &who) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!l", &pid, &who) == FAILURE) {
RETURN_THROWS();
}
/* needs to be cleared, since any returned value is valid */
errno = 0;
- pri = getpriority(who, pid);
+ pri = getpriority(who, pid_is_null ? getpid() : pid);
if (errno) {
PCNTL_G(last_error) = errno;
@@ -1235,14 +1236,15 @@ PHP_FUNCTION(pcntl_getpriority)
PHP_FUNCTION(pcntl_setpriority)
{
zend_long who = PRIO_PROCESS;
- zend_long pid = getpid();
+ zend_long pid;
+ zend_bool pid_is_null = 1;
zend_long pri;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|ll", &pri, &pid, &who) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|l!l", &pri, &pid, &who) == FAILURE) {
RETURN_THROWS();
}
- if (setpriority(who, pid, pri)) {
+ if (setpriority(who, pid_is_null ? getpid() : pid, pri)) {
PCNTL_G(last_error) = errno;
switch (errno) {
case ESRCH:
@@ -1401,14 +1403,16 @@ void pcntl_signal_dispatch()
Enable/disable asynchronous signal handling and return the old setting. */
PHP_FUNCTION(pcntl_async_signals)
{
- zend_bool on;
+ zend_bool on, on_is_null = 1;
- if (ZEND_NUM_ARGS() == 0) {
- RETURN_BOOL(PCNTL_G(async_signals));
- }
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &on) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b!", &on, &on_is_null) == FAILURE) {
RETURN_THROWS();
}
+
+ if (on_is_null) {
+ RETURN_BOOL(PCNTL_G(async_signals));
+ }
+
RETVAL_BOOL(PCNTL_G(async_signals));
PCNTL_G(async_signals) = on;
}
diff --git a/ext/pcntl/pcntl.stub.php b/ext/pcntl/pcntl.stub.php
index 5653244119..8dbc1c48e2 100644
--- a/ext/pcntl/pcntl.stub.php
+++ b/ext/pcntl/pcntl.stub.php
@@ -56,16 +56,16 @@ function pcntl_get_last_error(): int {}
function pcntl_errno(): int {}
#ifdef HAVE_GETPRIORITY
-function pcntl_getpriority(int $pid = UNKNOWN, int $process_identifier = PRIO_PROCESS): int|false {}
+function pcntl_getpriority(?int $pid = null, int $process_identifier = PRIO_PROCESS): int|false {}
#endif
#ifdef HAVE_SETPRIORITY
-function pcntl_setpriority(int $priority, int $pid = UNKNOWN, int $process_identifier = PRIO_PROCESS): bool{}
+function pcntl_setpriority(int $priority, ?int $pid = null, int $process_identifier = PRIO_PROCESS): bool{}
#endif
function pcntl_strerror(int $errno): string {}
-function pcntl_async_signals(bool $on = UNKNOWN): bool {}
+function pcntl_async_signals(?bool $on = null): bool {}
#ifdef HAVE_UNSHARE
function pcntl_unshare(int $flags): bool {}
diff --git a/ext/pcntl/pcntl_arginfo.h b/ext/pcntl/pcntl_arginfo.h
index 3310785cc3..a07033065f 100644
--- a/ext/pcntl/pcntl_arginfo.h
+++ b/ext/pcntl/pcntl_arginfo.h
@@ -91,7 +91,7 @@ ZEND_END_ARG_INFO()
#if defined(HAVE_GETPRIORITY)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_pcntl_getpriority, 0, 0, MAY_BE_LONG|MAY_BE_FALSE)
- ZEND_ARG_TYPE_INFO(0, pid, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, pid, IS_LONG, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, process_identifier, IS_LONG, 0, "PRIO_PROCESS")
ZEND_END_ARG_INFO()
#endif
@@ -99,7 +99,7 @@ ZEND_END_ARG_INFO()
#if defined(HAVE_SETPRIORITY)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcntl_setpriority, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, priority, IS_LONG, 0)
- ZEND_ARG_TYPE_INFO(0, pid, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, pid, IS_LONG, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, process_identifier, IS_LONG, 0, "PRIO_PROCESS")
ZEND_END_ARG_INFO()
#endif
@@ -109,7 +109,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcntl_strerror, 0, 1, IS_STRING,
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcntl_async_signals, 0, 0, _IS_BOOL, 0)
- ZEND_ARG_TYPE_INFO(0, on, _IS_BOOL, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, on, _IS_BOOL, 1, "null")
ZEND_END_ARG_INFO()
#if defined(HAVE_UNSHARE)