summaryrefslogtreecommitdiff
path: root/ext/pcntl/pcntl.c
diff options
context:
space:
mode:
authorMáté Kocsis <kocsismate@woohoolabs.com>2020-06-08 11:10:56 +0200
committerMáté Kocsis <kocsismate@woohoolabs.com>2020-06-09 09:46:51 +0200
commit596561009c8d7208db1b6506b68d92eefb11e6a2 (patch)
treec9d718d87865660edc815b77f68ba9baa0ad9e30 /ext/pcntl/pcntl.c
parentcadcefc956fd94a12580f7484caef91116456731 (diff)
downloadphp-git-596561009c8d7208db1b6506b68d92eefb11e6a2.tar.gz
Fix some UNKNOWN default values
In ext/ffi, ext/intl, ext/mysqli, and ext/pcntl
Diffstat (limited to 'ext/pcntl/pcntl.c')
-rw-r--r--ext/pcntl/pcntl.c26
1 files changed, 15 insertions, 11 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;
}