should be called with either EXIT_SUCCESS or EXIT_FAILURE */
| 1671 | |
| 1672 | /* should be called with either EXIT_SUCCESS or EXIT_FAILURE */ |
| 1673 | ATTRNORETURN void |
| 1674 | nh_terminate(int status) |
| 1675 | { |
| 1676 | program_state.in_moveloop = 0; /* won't be returning to normal play */ |
| 1677 | |
| 1678 | l_nhcore_call(NHCORE_GAME_EXIT); |
| 1679 | #ifdef MACOS9 |
| 1680 | getreturn("to exit"); |
| 1681 | #endif |
| 1682 | /* don't bother to try to release memory if we're in panic mode, to |
| 1683 | avoid trouble in case that happens to be due to memory problems */ |
| 1684 | if (!program_state.panicking) { |
| 1685 | freedynamicdata(); |
| 1686 | dlb_cleanup(); |
| 1687 | l_nhcore_done(); |
| 1688 | } |
| 1689 | |
| 1690 | #ifdef VMS |
| 1691 | /* |
| 1692 | * This is liable to draw a warning if compiled with gcc, but it's |
| 1693 | * more important to flag panic() -> really_done() -> nh_terminate() |
| 1694 | * as __noreturn__ then to avoid the warning. |
| 1695 | */ |
| 1696 | /* don't call exit() if already executing within an exit handler; |
| 1697 | that would cancel any other pending user-mode handlers */ |
| 1698 | if (program_state.exiting) |
| 1699 | return; |
| 1700 | #endif |
| 1701 | program_state.exiting = 1; |
| 1702 | nethack_exit(status); |
| 1703 | } |
| 1704 | |
| 1705 | /* set a delayed killer, ensure non-delayed killer is cleared out */ |
| 1706 | void |
no test coverage detected