Skip to content

Commit e7b2214

Browse files
committed
test
1 parent 20d648a commit e7b2214

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-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 (posix_getuid() !== 0) die('skip Test needs root user');
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, CLONE_NEWUSER);
18+
} catch (\ValueError $e) {
19+
echo $e->getMessage();
20+
}
21+
}
22+
?>
23+
--EXPECTF--
24+
pcntl_setns(): Argument #2 ($nstype) is an invalid nstype (%d)

0 commit comments

Comments
 (0)