Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64180 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14690 invoked from network); 6 Dec 2012 12:52:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Dec 2012 12:52:28 -0000 Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.42 as permitted sender) X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 209.85.160.42 mail-pb0-f42.google.com Received: from [209.85.160.42] ([209.85.160.42:38234] helo=mail-pb0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0A/00-14218-A0590C05 for ; Thu, 06 Dec 2012 07:52:26 -0500 Received: by mail-pb0-f42.google.com with SMTP id rp2so4278697pbb.29 for ; Thu, 06 Dec 2012 04:52:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=dUDcnK6Vvlr0h/Lz7irBZ8jdSsvFUaxLMskI4KWGEGY=; b=KSI6yp6bzNiItes/J0djuHyhVV3ajidivyjG41xMMUPZwWEXNb+egbAg7BCxqit1cx nkUTBWjRyNa3GI6HA1mGCeMvB+oByYcHgjlQ356OWa+2CHaYxznKIX810v+LPSQoro3V s6e9xYjdYbuNUYJ03awWpuu+zGIq7mDoquAnuYvz4nfexZ0JVUPVBdLaZ7cprcGEg9NK 8QZEMGXoeN2GPO1xGSMkhkwsdRj2FFZTwG05tyVqyk255AdEZ6UblMYtIk2irYYDArm8 lkm6AvTm4m5p2CHHiMc4XTqdLYDBPHD1NZ/yneL+DXJB79DdZub4RON0zOGWE9XNu2Y6 Zj+w== MIME-Version: 1.0 Received: by 10.66.84.132 with SMTP id z4mr3823964pay.63.1354798343883; Thu, 06 Dec 2012 04:52:23 -0800 (PST) Received: by 10.66.86.5 with HTTP; Thu, 6 Dec 2012 04:52:23 -0800 (PST) In-Reply-To: <50C0841E.6000507@gmail.com> References: <50C0841E.6000507@gmail.com> Date: Thu, 6 Dec 2012 13:52:23 +0100 Message-ID: To: =?ISO-8859-1?Q?=C1ngel_Gonz=E1lez?= Cc: PHP internals Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Passing process handles to proc_open and co From: pierre.php@gmail.com (Pierre Joye) hi, On Thu, Dec 6, 2012 at 12:40 PM, =C1ngel Gonz=E1lez wro= te: > On 06/12/12 09:49, Pierre Joye wrote: >> hi! >> >> While looking at the bug #63073, I was wondering if we could simply do >> not pass open handles to the newly created child process. > > Looking at proc_open, where there is an explicit CreateProcess (we seem > to be using the library popen for the exec()...) We use CreateProcess too for our windows popen implementation, see: http://lxr.php.net/xref/PHP_5_4/TSRM/tsrm_win32.c#450 > If $pipes is empty and $descriptorspec doesn't require more than 0,1,2 > then it should be safe not to set bInheritHandles. > > However, in other cases inheriting handles *will* be needed. hm, Why? >> The main issue in this bug is the session related handles. They are >> passed to the parent process, which hangs until their are closed. It >> indeed does not happen (usually) until the end of the request. It >> makes these functions almost unusable as soon as sessions are used. >> >> These functions are about calling external commands and I fail to see >> which usage may require to access PHP related handles. Does anyone see >> any issue by not passing them anymore? And fixing this bug (and a >> couple of other I think)? >> >> It is windows only. Not sure if we do the same on other platforms. > The issue was only detected with session files. Windows is probably the > only mainstream OS without F_SETFD. When it's available, mod_files.c > will set the FD_CLOEXEC, which should remove the issue from the session. > > The same issue could still arise from other files, though. For instance > bug 44994 reported that it was happening with error.log. > > > I don't know *why* session files are an issue. It would make sense if the= y > were pipes and the reading was missed with the inherited child unkowingly > holding a write descriptor, but these are plain files. > Maybe related to the fact that they are locked, if the locks are also > inherited, > plus the way Windows may delay its automatic UnlockFile() after the proce= ss > closes. > > -- Pierre @pierrejoye