Skip to content

Commit 96b1427

Browse files
committed
test
1 parent 20d648a commit 96b1427

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-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: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
?>
10+
--FILE--
11+
<?php
12+
$pid = pcntl_fork();
13+
if ($pid == -1) die("pcntl_fork failed");
14+
if ($pid != 0) {
15+
try {
16+
pcntl_setns($pid, 0);
17+
} catch (\ValueError $e) {
18+
echo $e->getMessage();
19+
}
20+
}
21+
?>
22+
--EXPECTF--
23+
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)