@@ -1196,17 +1196,18 @@ static void pcntl_siginfo_to_zval(int signo, siginfo_t *siginfo, zval *user_sigi
1196
1196
PHP_FUNCTION (pcntl_getpriority )
1197
1197
{
1198
1198
zend_long who = PRIO_PROCESS ;
1199
- zend_long pid = getpid ();
1199
+ zend_long pid ;
1200
+ zend_bool pid_is_null = 1 ;
1200
1201
int pri ;
1201
1202
1202
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "|ll " , & pid , & who ) == FAILURE ) {
1203
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "|l!l " , & pid , & who ) == FAILURE ) {
1203
1204
RETURN_THROWS ();
1204
1205
}
1205
1206
1206
1207
/* needs to be cleared, since any returned value is valid */
1207
1208
errno = 0 ;
1208
1209
1209
- pri = getpriority (who , pid );
1210
+ pri = getpriority (who , pid_is_null ? getpid () : pid );
1210
1211
1211
1212
if (errno ) {
1212
1213
PCNTL_G (last_error ) = errno ;
@@ -1235,14 +1236,15 @@ PHP_FUNCTION(pcntl_getpriority)
1235
1236
PHP_FUNCTION (pcntl_setpriority )
1236
1237
{
1237
1238
zend_long who = PRIO_PROCESS ;
1238
- zend_long pid = getpid ();
1239
+ zend_long pid ;
1240
+ zend_bool pid_is_null = 1 ;
1239
1241
zend_long pri ;
1240
1242
1241
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "l|ll " , & pri , & pid , & who ) == FAILURE ) {
1243
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "l|l!l " , & pri , & pid , & who ) == FAILURE ) {
1242
1244
RETURN_THROWS ();
1243
1245
}
1244
1246
1245
- if (setpriority (who , pid , pri )) {
1247
+ if (setpriority (who , pid_is_null ? getpid () : pid , pri )) {
1246
1248
PCNTL_G (last_error ) = errno ;
1247
1249
switch (errno ) {
1248
1250
case ESRCH :
@@ -1401,14 +1403,16 @@ void pcntl_signal_dispatch()
1401
1403
Enable/disable asynchronous signal handling and return the old setting. */
1402
1404
PHP_FUNCTION (pcntl_async_signals )
1403
1405
{
1404
- zend_bool on ;
1406
+ zend_bool on , on_is_null = 1 ;
1405
1407
1406
- if (ZEND_NUM_ARGS () == 0 ) {
1407
- RETURN_BOOL (PCNTL_G (async_signals ));
1408
- }
1409
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "|b" , & on ) == FAILURE ) {
1408
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "|b!" , & on , & on_is_null ) == FAILURE ) {
1410
1409
RETURN_THROWS ();
1411
1410
}
1411
+
1412
+ if (on_is_null ) {
1413
+ RETURN_BOOL (PCNTL_G (async_signals ));
1414
+ }
1415
+
1412
1416
RETVAL_BOOL (PCNTL_G (async_signals ));
1413
1417
PCNTL_G (async_signals ) = on ;
1414
1418
}
0 commit comments