| 906 | }; |
| 907 | |
| 908 | bool AppInitBasicSetup(const ArgsManager& args, std::atomic<int>& exit_status) |
| 909 | { |
| 910 | // ********************************************************* Step 1: setup |
| 911 | #ifdef _MSC_VER |
| 912 | // Turn off Microsoft heap dump noise |
| 913 | _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); |
| 914 | _CrtSetReportFile(_CRT_WARN, CreateFileA("NUL", GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, 0)); |
| 915 | // Disable confusing "helpful" text message on abort, Ctrl-C |
| 916 | _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); |
| 917 | #endif |
| 918 | #ifdef WIN32 |
| 919 | // Enable heap terminate-on-corruption |
| 920 | HeapSetInformation(nullptr, HeapEnableTerminationOnCorruption, nullptr, 0); |
| 921 | #endif |
| 922 | if (!SetupNetworking()) { |
| 923 | return InitError(Untranslated("Initializing networking failed.")); |
| 924 | } |
| 925 | |
| 926 | #ifndef WIN32 |
| 927 | // Clean shutdown on SIGTERM |
| 928 | registerSignalHandler(SIGTERM, HandleSIGTERM); |
| 929 | registerSignalHandler(SIGINT, HandleSIGTERM); |
| 930 | |
| 931 | // Reopen debug.log on SIGHUP |
| 932 | registerSignalHandler(SIGHUP, HandleSIGHUP); |
| 933 | |
| 934 | // Ignore SIGPIPE, otherwise it will bring the daemon down if the client closes unexpectedly |
| 935 | signal(SIGPIPE, SIG_IGN); |
| 936 | #else |
| 937 | SetConsoleCtrlHandler(consoleCtrlHandler, true); |
| 938 | #endif |
| 939 | |
| 940 | std::set_new_handler(new_handler_terminate); |
| 941 | |
| 942 | return true; |
| 943 | } |
| 944 | |
| 945 | bool AppInitParameterInteraction(const ArgsManager& args) |
| 946 | { |
no test coverage detected