#5402: Exit code is wrong with dynamically loaded libraries
---------------------------------+------------------------------------------
Reporter: Lennart | Owner:
Type: bug | Status: new
Priority: normal | Component: Runtime System
Version: 7.1 | Keywords:
Testcase: | Blockedby:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
Here's a simple scenario that goes wrong:
Program starts, calls hs_init(), hs_init_count=1
Program loads some Haskell library that calls hs_init(), hs_init_count=2.
Program does exitWith 99, which calls shutdownHaskellAndExit(99), which
calls hs_exit_(). Since hs_init_count>1 it will do nothing. Control
returns to shutdownHaskellAndExit, since hs_init_count>0 it will do
nothing, i.e., it throws away the exit code 99.
Now real_main() gets control back, and calls shutdownHaskellAndExit(0).
The whole program now exits with code 0, rather than 99.
The solution is probably to track the last non-0 exit code encountered in
shutdownHaskellAndExit and use that as the exit code in real_main().
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5402>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs