Skip to content

Commit 2d0a79f

Browse files
committed
Also clear the stat cache in the forked child
1 parent a8cc413 commit 2d0a79f

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

‎ext/pcntl/pcntl.c‎

Lines changed: 4 additions & 3 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"
@@ -294,7 +295,7 @@ PHP_FUNCTION(pcntl_fork)
294295
}
295296
} else if (id == 0) {
296297
zend_max_execution_timer_init();
297-
realpath_cache_clean();
298+
php_clear_stat_cache(true, NULL, 0);
298299
}
299300

300301
RETURN_LONG((zend_long) id);
@@ -1574,7 +1575,7 @@ PHP_FUNCTION(pcntl_rfork)
15741575
}
15751576
} else if (pid == 0) {
15761577
zend_max_execution_timer_init();
1577-
realpath_cache_clean();
1578+
php_clear_stat_cache(true, NULL, 0);
15781579
}
15791580

15801581
RETURN_LONG((zend_long) pid);
@@ -1620,7 +1621,7 @@ PHP_FUNCTION(pcntl_forkx)
16201621
}
16211622
} else if (pid == 0) {
16221623
zend_max_execution_timer_init();
1623-
realpath_cache_clean();
1624+
php_clear_stat_cache(true, NULL, 0);
16241625
}
16251626

16261627
RETURN_LONG((zend_long) pid);

‎ext/pcntl/tests/gh23986.phpt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ function proc_self_pid() {
1313
}
1414

1515
var_dump(proc_self_pid() === getmypid());
16+
$parent_inode = fileinode('/proc/self');
1617

1718
$pid = pcntl_fork();
1819
if ($pid === 0) {
20+
var_dump(fileinode('/proc/self') !== $parent_inode);
1921
var_dump(proc_self_pid() === getmypid());
2022
exit(0);
2123
}
@@ -24,3 +26,4 @@ pcntl_waitpid($pid, $status);
2426
--EXPECT--
2527
bool(true)
2628
bool(true)
29+
bool(true)

0 commit comments

Comments
 (0)