Skip to content

Commit 35a9f77

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: Fix GH-23986: Clear the realpath cache in the child after pcntl_fork() (#23987)
2 parents 8c22556 + 023ee4d commit 35a9f77

4 files changed

Lines changed: 33 additions & 0 deletions

File tree

‎NEWS‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ PHP NEWS
9393
an exception is pending. (nicolas-grekas)
9494
. Fixed pcntl_signal_dispatch() dropping the signals queued behind a handler
9595
that throws. (nicolas-grekas)
96+
. Fixed bug GH-23986 (/proc/self paths resolve to the parent process after
97+
pcntl_fork()). (Lazizbek Ergashev)
9698

9799
- PDO:
98100
. Fixed PDOStatement::getColumnMeta() reading out of bounds for an invalid

‎ext/pcntl/pcntl.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
#include "php.h"
3131
#include "ext/standard/info.h"
32+
#include "ext/standard/php_filestat.h"
3233
#include "php_signal.h"
3334
#include "php_ticks.h"
3435
#include "zend_exceptions.h"

‎ext/pcntl/tests/gh23986.phpt‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
GH-23986 (/proc/self paths resolve to the parent process after pcntl_fork())
3+
--EXTENSIONS--
4+
pcntl
5+
--SKIPIF--
6+
<?php
7+
if (!is_readable('/proc/self/stat')) die('skip /proc/self/stat not available');
8+
?>
9+
--FILE--
10+
<?php
11+
function proc_self_pid() {
12+
return (int) explode(' ', file_get_contents('/proc/self/stat'))[0];
13+
}
14+
15+
var_dump(proc_self_pid() === getmypid());
16+
$parent_inode = fileinode('/proc/self');
17+
18+
$pid = pcntl_fork();
19+
if ($pid === 0) {
20+
var_dump(fileinode('/proc/self') !== $parent_inode);
21+
var_dump(proc_self_pid() === getmypid());
22+
exit(0);
23+
}
24+
pcntl_waitpid($pid, $status);
25+
?>
26+
--EXPECT--
27+
bool(true)
28+
bool(true)
29+
bool(true)

‎main/main.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,6 +1866,7 @@ PHPAPI void php_child_init(void)
18661866
{
18671867
refresh_memory_manager();
18681868
zend_max_execution_timer_init();
1869+
php_clear_stat_cache(true, NULL, 0);
18691870
}
18701871

18711872
/* {{{ php_request_startup */

0 commit comments

Comments
 (0)