[phobos] Removing std.stdio.File.popen()
Lars Tandle Kyllingstad
lars at kyllingen.net
Wed Aug 18 02:10:44 PDT 2010
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?
-Lars
More information about the phobos
mailing list