Re: [PHP4BETA] PHP and cwd/chdir in a threaded environment
| From: | David Hedbor | Date: | Wed, 24 Nov 1999 00:34:25 +0000 |
| Subject: | Re: [PHP4BETA] PHP and cwd/chdir in a threaded environment | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-6800@lists.php.net to get a copy of this message | ||
Rasmus Lerdorf <rasmus@lerdorf.on.ca> writes:
> > I see another potential problem with using PHP in a threaded
> > environment - chdir is generally a nono. They are not thread-local but
> > process global. Even though my current php implementation is run in a
> > serial manner (the PHP module has a lock in it), Roxen wouldn't like
> > getting the current directory being changed. This cause two problems:
> >
> > 1) PHP scripts expect CWD to be the current directory. inserts
> > wouldn't work unless the complete path is used.
> > 2) chdir from a PHP script would (could) mess up Roxen.
> >
> > My suggestion is to use a "virtual" file system model in PHP. Ie, have
> > the "cwd" be a variable in the of the script global structs. Every
> > time you open a file with a relative path use the "cwd" from that
> > structure as the base directory.
> >
> > It should really be a rather easy thing to implement since it doesn't
> > affect that many functions.
>
> What about existing scripts that do any sort of system/exec/popen/passthru?
> They would break.
>
> I agree that this is probably the best solution and that we need to do
> something here, but I don't think we can make this backward compatible to
> the user.
It should be possible to make PHP use those calls correctly. Although
it would be harder, it's doable. Since I don't know how those calls
are implemented (ie do they use system/popen, a custom fork/execve
solution or whatever) I can't say exactly how hard it would be. In
general those system calls can cause troubles when running in threaded
mode.
It might be necessary for the Roxen PHP module to (pre)fork a number
of "PHP-processes" that can change directories etc all they want, even
though I'd rather not see such a solution.
--
[ Below is a random fortune, which is unrelated to the above message. ]
In any formula, constants (especially those obtained from handbooks)
are to be treated as variables.