Req #40661 [Opn]: cwd is reset when shutdown handler runs
| From: | cmb@php.net | Date: | Mon, 11 Oct 2021 13:52:06 +0000 |
| Subject: | Req #40661 [Opn]: cwd is reset when shutdown handler runs | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-237144@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=40661&edit=1
ID: 40661
Updated by: cmb@php.net
Reported by: derick@php.net
Summary: cwd is reset when shutdown handler runs
Status: Open
Type: Feature/Change Request
Package: Apache related
Operating System: Linux
PHP Version: 5.2.5
Block user comment: N
Private report: N
New Comment:
> Making sure this doesn't slip through the cracks..
Didn't work. :)
While it shouldn't be hard to restore the CWD during the shutdown
handler, I wonder whether we should do it. After that long time,
most code likely has adapted to do this manually (or doesn't use
relative paths in the first place), and some code may even use the
CWD reset on purpose (BC break).
Anyhow, this change is unlikely to happen, unless somebody submits
a PR.
Previous Comments:
------------------------------------------------------------------------
[2021-01-07 14:21:06] cmb@php.net
Related To: Bug #80527
------------------------------------------------------------------------
[2007-07-11 12:35:37] jani@php.net
Making sure this doesn't slip through the cracks..also found in PHP 5.2
------------------------------------------------------------------------
[2007-02-27 15:00:13] derick@php.net
I disagree, there is no reason why PHP can't reset the CWD to the correct directory when a
shutdown handler is run. That is what I would expect to happen.
------------------------------------------------------------------------
[2007-02-27 14:54:34] tony2001@php.net
See http://bugs.php.net/bug.php?id=36529
------------------------------------------------------------------------
[2007-02-27 14:44:41] derick@php.net
Description:
------------
When this script is run with the Apache1 sapi the second CWD is reset to /.
This is an issue for both php 4.4.4 and php 5.2.1rc3.
Reproduce code:
---------------
<?php
echo "CWD = ", getcwd(), "\n";
function handler()
{
echo "CWD = ", getcwd(), "\n";
echo dirname( __FILE__ ), "\n";
}
register_shutdown_function( 'handler' );
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=40661&edit=1