|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #40661 cwd is reset when shutdown handler runs
Submitted: 2007-02-27 14:44 UTC Modified: 2011-04-08 21:22 UTC
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:2 (66.7%)
From: Assigned:
Status: Open Package: Apache related
PHP Version: 5.2.5 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
New email:
PHP Version: OS:


 [2007-02-27 14:44 UTC]
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:
echo "CWD = ", getcwd(), "\n";

function handler()
    echo "CWD = ", getcwd(), "\n";
    echo dirname( __FILE__ ), "\n";

register_shutdown_function( 'handler' );


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-27 15:00 UTC]
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-07-11 12:35 UTC]
Making sure this doesn't slip through the cracks..also found in PHP 5.2
 [2011-04-08 21:22 UTC]
-Package: Feature/Change Request +Package: Apache related
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Sep 20 03:03:36 2021 UTC