Skip to content

Commit 878f6ec

Browse files
committed
test
1 parent 20d648a commit 878f6ec

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

ext/pcntl/pcntl.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,9 @@ PHP_FUNCTION(pcntl_setns)
14421442
case ENOMEM:
14431443
php_error_docref(NULL, E_WARNING, "Error %d: Insufficient memory for pidfd_open", errno);
14441444
break;
1445+
1446+
default:
1447+
php_error_docref(NULL, E_WARNING, "Error %d", errno);
14451448
}
14461449
RETURN_FALSE;
14471450
}
@@ -1462,6 +1465,9 @@ PHP_FUNCTION(pcntl_setns)
14621465
case EPERM:
14631466
php_error_docref(NULL, E_WARNING, "Error %d: No required capability for this process", errno);
14641467
break;
1468+
1469+
default:
1470+
php_error_docref(NULL, E_WARNING, "Error %d", errno);
14651471
}
14661472
RETURN_FALSE;
14671473
} else {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
pcntl_setns()
3+
--EXTENSIONS--
4+
pcntl
5+
posix
6+
--SKIPIF--
7+
<?php
8+
if (!function_exists("pcntl_setns")) die("skip pcntl_setns is not available");
9+
if (getenv('SKIP_ASAN')) die('skip Timeouts under ASAN');
10+
?>
11+
--FILE--
12+
<?php
13+
$pid = pcntl_fork();
14+
if ($pid == -1) die("pcntl_fork failed");
15+
if ($pid != 0) {
16+
try {
17+
pcntl_setns($pid, 0);
18+
} catch (\ValueError $e) {
19+
echo $e->getMessage();
20+
}
21+
}
22+
?>
23+
--EXPECTF--
24+
pcntl_setns(): Argument #2 ($nstype) is an invalid nstype (%d)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
pcntl_setns()
3+
--EXTENSIONS--
4+
pcntl
5+
posix
6+
--SKIPIF--
7+
<?php
8+
if (!function_exists("pcntl_setns")) die("skip pcntl_setns is not available");
9+
if (posix_getuid() !== 0) die('skip Test needs root user');
10+
if (getenv('SKIP_ASAN')) die('skip Timeouts under ASAN');
11+
?>
12+
--FILE--
13+
<?php
14+
$pid = pcntl_fork();
15+
if ($pid == -1) die("pcntl_fork failed");
16+
if ($pid != 0) {
17+
var_dump(pcntl_setns($pid, CLONE_NEWPID));
18+
}
19+
?>
20+
--EXPECT--
21+
bool(true)

0 commit comments

Comments
 (0)