shell_exec, environment, and multithreading servers
| From: | jvlad | Date: | Sun, 24 May 2009 17:43:13 +0000 |
| Subject: | shell_exec, environment, and multithreading servers | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-44047@lists.php.net to get a copy of this message | ||
Hi all,
Recently I faced with one funny problem in PHP. Seems there is no way to run
a sub-process using shell_exec() (or backticks), and pass there specially
crafted environment without affecting all running threads. As soon as I
update the environment, all other threads see the change. It's
multithreading nature to be running under the same process and share the
process environment, no problems so far, but there should be a way to run
sub-process with appropriate set of environment variables without affecting
all the threads.
Looks like for Win32 target, there is a popenex() function that is called by
shell_exec and this function has env parameter. I think it makes sense to
pass $_ENV in this argument. Certainly, $_ENV should be converted into array
of pointers.
Not sure if there is any way under unix other than using execXX() instead
of popen() to get the same behaviour.
Thoughts?
-jv