[phobos] Removing std.stdio.File.popen()

Andrei Alexandrescu andrei at erdani.com
Wed Aug 18 02:55:46 PDT 2010


On 08/18/2010 04:10 AM, Lars Tandle Kyllingstad wrote:
> On Wed, 2010-08-18 at 10:17 +0200, Lars Tandle Kyllingstad wrote:
>> On Tue, 2010-08-17 at 23:46 -0500, Andrei Alexandrescu wrote:
>>> Incidentally a colleague of mine mentioned today a much faster
>>> implementation of popen():
>>>
>>> http://blog.famzah.net/2009/11/20/a-much-faster-popen-and-system-implementation-for-linux/
>>>
>>> http://code.google.com/p/popen-noshell/
>>>
>>> We should get that in Phobos.
>>
>> This is very useful information!  I'll see if this can be incorporated
>> in the new std.process.
>
> I had a more thorough look at it now, and from what I can understand,
> this trick trades safety for speed.
>
> Instead of fork(), it calls clone().  This allows the child to run in
> the same memory space as the parent (but with a separate stack), which
> avoids the overhead of duplicating the parent's memory.  This is all
> well and good if you're sure you can trust the program you're calling to
> be both bug-free and non-malicious, but in general I would be reluctant
> to do so.
>
> There is of course a good chance that I may be missing some part of the
> trick that he's not mentioning in the article.  The code itself is
> GPL'ed, so I don't want to look at it.  Can anyone here think of a way
> to make this safe?

Doesn't he call exec() immediately after clone()?

Andrei


More information about the phobos mailing list