Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:44083 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29061 invoked from network); 28 May 2009 13:21:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 May 2009 13:21:45 -0000 X-Host-Fingerprint: 85.21.236.169 xdmitri.static.corbina.ru Received: from [85.21.236.169] ([85.21.236.169:13680] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2F/07-31798-7EF8E1A4 for ; Thu, 28 May 2009 09:21:43 -0400 Message-ID: <2F.07.31798.7EF8E1A4@pb1.pair.com> To: internals@lists.php.net References: <6B.C0.13990.237891A4@pb1.pair.com> <10845a340905280330k72ee009ajc4291935a79c7f00@mail.gmail.com> Date: Thu, 28 May 2009 17:21:43 +0400 Lines: 49 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5512 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-Posted-By: 85.21.236.169 Subject: Re: [PHP-DEV] shell_exec, environment, and multithreading servers From: dmda@yandex.ru ("jvlad") >> Recently I faced with one funny problem in PHP. Seems there is no way to >> run >> a sub-process using 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 >Does resource proc_open ( string $cmd , array $descriptorspec , array >&$pipes [, string $cwd [, array $env [, array $other_options ]]] ) for >the bill here? That's correct, but what to do with existing code that I need to use? I don't want to replace all constructs like $a = `$mycmd $cmdline`; with many lines required for popenex(). I would not like this way even if only one symbol should be changed in the 3rd party code. Why not to enhance semantic of exec() and backticks functions? Why not to run child process with copy of $_ENV[] instead of current process envrironment? With multithreading servers you can't change current process's enviroment without affecting all the threads, but you can easily and safely change $_ENV[]. -jv