Skip to content

Commit 34e7d78

Browse files
committed
Improve privilege check in pcntl_setpriority() test
We need CAP_SYS_NICE privileges, which might not be available just because we're running as root (Docker...)
1 parent fcfa0a4 commit 34e7d78

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ext/pcntl/tests/pcntl_setpriority_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ if (!extension_loaded('pcntl')) {
1111
if (!function_exists('pcntl_setpriority')) {
1212
die('skip pcntl_setpriority doesn\'t exist');
1313
}
14-
if (!function_exists('posix_getuid') || posix_getuid() !== 0) {
15-
die('skip this functions needs to run with superuser');
14+
if (@pcntl_setpriority(-5) === false && pcntl_get_last_error() == PCNTL_EACCES) {
15+
die('skip this function needs to run with CAP_SYS_NICE privileges');
1616
}
1717
?>
1818
--FILE--

0 commit comments

Comments
 (0)