Follow up - Oh! FFI exporting your function outputs a stub that does all
that extra stuff... mostly (just misses returning the exit status from the
capability, but that's cool, I don't really need those particular messages
at the end of real_main()... )

Thanks, Gregory!

- Mark

On Fri, Apr 27, 2012 at 8:15 AM, Mark Lentczner <[email protected]> wrote:

> Aha - I realize now that my program is linked -threaded, which is why the
> IO manager gets started before main: (from rts/RtsStartup.c)
>
> #if defined(THREADED_RTS)
>     ioManagerStart();
> #endif
>
>
> On Fri, Apr 27, 2012 at 6:57 AM, Gregory Collins 
> <[email protected]>wrote:
>
>> Have you thought about calling hs_init() from your own C main() function?
>> You can set up the file descriptors however you like if you do this. See
>> ยง8.2.1.1 here:
>> http://www.haskell.org/ghc/docs/7.4.1/html/users_guide/ffi-ghc.html .
>>
>
> That's a good idea - Though I don't see how to call exactly to get my
> original main function invoked. Reading the rts, looks like I want to call
> hs_main, but pass in the magic top closure... not sure how to find that
> (will do linker spelunking later). I see in haskeline source there is an
> example of calling hs_init() in an alternative main. And there it just
> calls some haskell function directly. But I notice that there is a whole
> bunch of initialization and work done in hs_main() and real_main() in the
> rts that would be missed by this approach.
>
> - Mark
>
>
_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to