[jhc] darcs patch: add System.IO.Pipe.
David Roundy
daveroundy at gmail.com
Mon Sep 21 13:50:05 EDT 2009
On Sun, Sep 20, 2009 at 7:01 PM, John Meacham <john at repetae.net> wrote:
> On Sun, Sep 20, 2009 at 06:26:30PM -0400, David Roundy wrote:
>> This patch adds support for popen/pclose. It's a bit hokey, and
>> doesn't quite work right. In particular, I get an error if I try to
>> use getErrno in openPipe. gcc complains about errno not being
>> defined, because errno.h isn't included. For the moment, openPipe
>> just doesn't check for errors, but that isn't a great long-term
>> solution.
>
> errno.h is ISO C, so we can include it in src/data/rts/jhc_rts_header.h
> without issue.
I'm confused, though, as to why this would be needed. I looked at the
foreign import that defined errno (and getErrno), and it seems like it
specifies the header file, so I thought i would be included
automatically...
>> So far as I can discern, this is portable code, at least to mingw,
>> which is as far into windows as I care to venture.
>
> cool. I should modify the regressions to test with mingw/wine when they
> are available actually.
That'd be nice... I imagine you could look at the targets.ini files to
see if they're available. That's how my mingw is configured, anyhow.
>> P.S. I'd much rather have System.Process ported, but gave up on doing
>> this myself after realizing that I'd have to implement much of
>> GHC.Handle in order to do this, since we'd have to work with file
>> descriptors rather than FILE *. :(
>
> Is this true? can't we just use fdopen(3) to turn the descriptors into
> handles?
You're absolutely right. I had suspected that there was such a system
call, but couldn't remember its name, and didn't come across it.
Although the name is pretty obvious... except that you aren't actually
opening anything.
Porting System.Process to jhc does, however, require dealing with lots
of nasty code, and also requires that we deal with windows separately,
which is scary. And I'm not sure whether there is something
fdopen-like on windows (or if it's needed).
--
David Roundy
More information about the jhc
mailing list