Exit code is wrong with dynamically loaded libraries
|Reported by:||Lennart||Owned by:|
|Type of failure:||None/Unknown||Test Case:||ffi/should_run/5402|
|Related Tickets:||Differential Rev(s):|
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().
Change History (13)
comment:9 Changed 6 years ago by
|Status:||new → closed|
|Test Case:||→ ffi/should_run/5402|