Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52131 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96753 invoked from network); 5 May 2011 00:30:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 May 2011 00:30:49 -0000 Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-ew0-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:46268] helo=mail-ew0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CF/98-29688-6BFE1CD4 for ; Wed, 04 May 2011 20:30:46 -0400 Received: by ewy2 with SMTP id 2so501405ewy.29 for ; Wed, 04 May 2011 17:30:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=Wf7HRvtA176dPEJXH2u2uc2dCjzKVyFXBKQeCt7cFOw=; b=Iu4UFrLZzfjGiI+HsiNMO+1GDBBqRXJv2GFUOgRqe+sASfyyBeA3huEZpJhwqHIQ4/ HyFe1MxukIOMdGdVo4niC6AegtGx/uEixp1UnzVtUsaGsaOvksGvycFxLOqYPRv73eR3 TMRGPeSzzbOnqOaWEe/OHt5YdhUPJNvirqizU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=uCmjV7WDYB1MjwwctOA3s4HbUpYf32KV2/5pR5Sxg7A3iFJ90dWxxUVqSnblFwnVSt IrfG/8YosQaPxl7NyiSdPxoPF4V/BgMsaurnCdWxgLrYxqnjaZu0bGzvIKcUZBnqddca KXoRx+tYYiSJ6v9thdXIts0e9a2Ba76HzBVX0= MIME-Version: 1.0 Received: by 10.14.41.155 with SMTP id h27mr844279eeb.199.1304555442011; Wed, 04 May 2011 17:30:42 -0700 (PDT) Sender: tyra3l@gmail.com Received: by 10.14.127.79 with HTTP; Wed, 4 May 2011 17:30:41 -0700 (PDT) In-Reply-To: References: Date: Thu, 5 May 2011 02:30:41 +0200 X-Google-Sender-Auth: _6lhOZ93J9TSZEdaNMg9Q9HfrwU Message-ID: To: Gustavo Lopes Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=0016e657b06ab5ff3b04a27c7b9e Subject: Re: [PHP-DEV] adding low level file handling stuff From: info@tyrael.hu (Ferenc Kovacs) --0016e657b06ab5ff3b04a27c7b9e Content-Type: text/plain; charset=UTF-8 On Sat, Apr 30, 2011 at 5:23 PM, Ferenc Kovacs wrote: > I actually did consider adding support for an extended form of php://fd >> where one would specify the desired file descriptor: php://fd//> fd>. It would call dup2 instead of dup. >> >> However, I got into some trouble on shutdown because this could cause >> stdout to be closed ahead of time and then the output subsystem would cause >> either a segfault or a memory leak (can't recall). I didn't spend more than >> 20 minutes on this as it was not the problem I was trying to solve, so >> there's probably an easy solution. If you want to work on this, extending >> php://fd would likely be a good place. >> >> -- >> Gustavo Lopes >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > thanks Gustavo. > as you check my mail, I also mentioned using dup2 instead of dup, for > obvious reasons. > adding dup2 support for the php://fd stream would be better than the > current situation, but I can't see why are we trying to force everything > into that. > I mean everything on the http://www.php.net/manual/en/wrappers.php can be > achived through a function also. > there are some case when you can save a couple of lines of code with the > wrappers and with http://www.php.net/manual/en/context.http.php but there > is no method for opening FDs or the dup2 that you mentioned. > I think that it would be more consistent with the rest of the language, and > one would more likely to find fdopen than fopen('php://fd/1'); in the > documentation. > > closing the stdout without reopening also caused problems for me in case of > an error happens, but this shouldn't happen if you properly reopen it, so I > would be interested what exactly happened there. > > Tyrael > I put together the fileno, fdopen, dup2, fclose stuff as a pecl extension(called fildes), the sourcecode available here: https://github.com/Tyrael/php-fildes with this, you can do something like this: