[Haskell-cafe] How does the RTS "know" about ExitCode
lists at utdemir.com
Wed Jul 15 21:11:42 UTC 2020
I also didn't know that, so I looked at the source, and found out that GHC has a wrapper around `main` which (besides a few other stuff) is responsible for catching exceptions including the ExitCode and figuring out the appropriate exit code. In order to actually exit the program, `shutdownHaskellAndExit` C function from RTS  is called from there which takes the exit code as a parameter.
This was good to know, thanks for the question!
On Thu, Jul 16, 2020, at 12:05 AM, Georgi Lyubenov wrote:
> I'm wondering how values stored in ExitCode "get to" the RTS (i.e. actually make the program exit with the given number).
> As far as I can tell ExitCode is used as an everyday normal-looking exception (which are defined entirely in "library code", by using the raise#/catch# primitives), without any direct link to the RTS.
> What am I missing?
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe