<!DOCTYPE html><html><head><title></title><style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div>I also didn't know that, so I looked at the source, and found out that GHC has a wrapper[1] 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 [2] is called from there which takes the exit code as a parameter.<br></div><div><div><br></div></div><div>This was good to know, thanks for the question!<br></div><div><div><br></div></div><div id="sig64951536"><div><div>Utku<br></div><div><div><br></div></div><div>[1]: <a href="https://gitlab.haskell.org/ghc/ghc/-/blob/ae11bdfd98a10266bfc7de9e16b500be220307ac/libraries/base/GHC/TopHandler.hs" rel="noopener noreferrer" target="_blank">https://gitlab.haskell.org/ghc/ghc/-/blob/ae11bdfd98a10266bfc7de9e16b500be220307ac/libraries/base/GHC/TopHandler.hs</a> <br></div><div><div>[2]: <a href="https://gitlab.haskell.org/ghc/ghc/-/blob/ae11bdfd98a10266bfc7de9e16b500be220307ac/rts/RtsStartup.c#L554" style="font-size:0.820312rem;" rel="noopener noreferrer" target="_blank">https://gitlab.haskell.org/ghc/ghc/-/blob/ae11bdfd98a10266bfc7de9e16b500be220307ac/rts/RtsStartup.c#L554</a><br></div></div></div></div><div><br></div><div><br></div><div>On Thu, Jul 16, 2020, at 12:05 AM, Georgi Lyubenov wrote:<br></div><blockquote type="cite" id="qt" style=""><div dir="ltr"><div>Hi!<br></div><div><br></div><div>I'm wondering how values stored in ExitCode "get to" the RTS (i.e. actually make the program exit with the given number).<br></div><div><br></div><div>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. <br></div><div><br></div><div>What am I missing?<br></div><div><br></div><div>======<br></div><div>Georgi<br></div></div><div>_______________________________________________<br></div><div>Haskell-Cafe mailing list<br></div><div>To (un)subscribe, modify options or view archives go to:<br></div><div><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br></div><div>Only members subscribed via the mailman list are allowed to post.<br></div></blockquote><div><br></div></body></html>